Here Mudassar Ahmed Khan has explained how to pass value from child popup window to parent page window using JavaScript.

The child popup window must be opened using JavaScript window.open function. And in such case we can access the parent page controls using JavaScript window.opener instance.

In this article I will explain how to pass value from child popup window to parent page window using JavaScript.
The child popup window must be opened using JavaScript window.open function. And in such case we can access the parent page controls using JavaScript window.opener instance.
 
Parent Page
Inside the Parent Page I have placed a TextBox which is read-only and a button to open the child popup window using the SelectNameJavaScript function.
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
Name:&nbsp;
</td>
<td>
<input type="text" id="txtName" readonly="readonly" />
</td>
<td>
<input type="button" value="Select Name" onclick="SelectName()" />
</td>
</tr>
</table>
<script type="text/javascript">
var popup;
function SelectName() {
popup = window.open("Popup.htm", "Popup", "width=300,height=100");
popup.focus();
}
</script>
Popup Child Window Page
The Popup Child Window Page has a DropDownList to choose the name of the person and a button which when clicked calls the SetNameJavaScript function.
This function uses the reference of window.opener property and finds the Parent Page txtName TextBox using document.getElementById method of JavaScript and sets the value selected through the DropDownList to it.
<select name="ddlNames" id="ddlNames">
<option value="Mudassar Khan">Mudassar Khan</option>
<option value="John Hammond">John Hammond</option>
<option value="Mike Stanley">Mike Stanley</option>
</select>
<br />
<br />
<input type="button" value="Select" onclick="SetName();" />
<script type="text/javascript">
function SetName() {
if (window.opener != null && !window.opener.closed) {
var txtName = window.opener.document.getElementById("txtName");
txtName.value = document.getElementById("ddlNames").value;
}
window.close();
}
</script>
In similar way you can access other controls too of the Parent Page from the Child Popup Window Page

 
Demo
refernce:
http://www.aspsnippets.com/Articles/Pass-value-from-child-popup-window-to-parent-page-window-using-JavaScript.aspx

Pass value from child popup window to parent page window using JavaScript--reference的更多相关文章

  1. window.parent 与 window.opener

    window.parent针对iframe,window.opener针对window.open 父页面parent.jsp: <%@ page language="java" ...

  2. Android IllegalStateException: The specified child already has a parent问题解决办法

    最近遇到一个很让人头疼的问题,使用viewpager动态添加页面或者删除页面时出现了问题(java.lang.IllegalStateException: The specified child al ...

  3. java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.

    在ViewPager中,用Fragment显示页面时,报错: java.lang.IllegalStateException: The specified child already has a pa ...

  4. window.parent与window.openner区别介绍

    今天总结一下js中几个对象的区别和用法: 首先来说说 parent.window与top.window的用法 "window.location.href"."locati ...

  5. window.self ->window.top->window.parent

    在应用有frameset或者iframe的页面时,parent是父窗口,top是最顶级父窗口(有的窗口中套了好几层frameset或者iframe),self是当前窗口, opener是用open方法 ...

  6. JavaScript中,window.opener是什么?window.parent和window.opener有啥区别?

    来自CSDN的问答: window.opener是什么啊? ++++++++++++++++++++++++++++++++++++++++++++++++++ 弹出本窗体的句柄 比如你想点一个按钮直 ...

  7. The specified child already has a parent错误

    10-05 23:39:48.187: E/AndroidRuntime(12854): Caused by: java.lang.IllegalStateException: The specifi ...

  8. window.parent与window.openner

    window.parent与window.openner区别介绍 作者: 字体:[增加 减小] 类型:转载 今天总结一下js中几个对象的区别和用法,对这几个概念混淆的朋友可以看看 今天总结一下js中几 ...

  9. bug_ _fragment_“The specified child already has a parent. You must call removeView"的解决以及产生的原因

    这个异常的出现往往是因为非法使用了某些方法引起的. 从字面意思上是说这个特定的child已经有一个parent了,你必须在这个parent中首先调用removeView()方法,才能继续你的内容.这里 ...

随机推荐

  1. html在图片上实现下雨效果

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...

  2. 测试xss和xsf

    xss注入攻击: 123123123 被动注入: 1231231231231231 主动注入: 对不起,你需要登录才能评论 用户名 密码

  3. Vim小知识

    在退出vim编辑的时候,强制退出是q! 感叹号在前,即!q,表示执行外部shell命令,感叹号在后,即q!,表示强制执行vi命令.

  4. oc_转_构造对象的方法,以及类的继承

    一.构造方法 (一)构造方法的调用 完整的创建一个可用的对象:Person *p=[Person new]; New方法的内部会分别调用两个方法来完成2件事情: 1) 使用alloc方法来分配存储空间 ...

  5. leetcode—sqrt

    1.题目描述   Implement int sqrt(int x).   Compute and return the square root of x. 2.解法分析 很明显,用二分搜索可解,但是 ...

  6. 见过的最好AWK手册

    原文: http://linuxfire.com.cn/~lily/awk.html 简体中文版由bones7456 (http://li2z.cn)整理. 原文:应该是 http://phi.sin ...

  7. [COCOS2D-X]AssetsManager

    转自:http://blog.csdn.net/xpwang168/article/details/8900764 资源更新方式分析 I zip整包更新 优点:省流量,速度快 缺点:有重复资源,需要打 ...

  8. JavaScript如何判断参数为浮点型

    在codewars里,确实可以学到很多很酷的方法,例如这一次的题目是判断数字是否为浮点型.我一开始是想有没有原生的js方法,像isNaN(),isFinite(),在前者Infinity是不属于NaN ...

  9. hadoop conf中xml文件修改

    core-site.xml <?xml version="1.0"?><?xml-stylesheet type="text/xsl" hre ...

  10. ASP.NET MVC- Area 使用

    ASP.NET MVC允许使用 Area(区域)来组织Web应用程序,每个Area代表应用程序的不同功能模块.这对于大的工程非常有用,Area 使每个功能模块都有各自的文件夹,文件夹中有自己的Cont ...