469,295 Members | 1,953 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,295 developers. It's quick & easy.

Pass values between parent and popup window


I am writing a small java script code where , when the textbox is clicked a pop up window is opened . on entering some data in the text area present in pop up window and pressing ''save" button the pop up is closed and the value is put in the text box of parent window. Now the value is getting passed from pop up to parent but from parent to pop up i am unable to pass the value.

the following is the code to pass the value from pop up to parent window:

[HTML]<script type="text/javascript">
function abc()
var wind1=null;
var tmp=null;
wind1 = window.open('', 'displayWindow', 'width=400,height=300,status=no,toolbar=no,menubar =no,scrollbars=1');
wind1.document.write("<script> function alert1(f){");
wind1.document.write("var frmdst=f.ta.value;");
wind1.document.write("window.opener.getValues();") ;
wind1.document.write("<html><body><form action='#' name='myform' action='post'><TEXTAREA rows='2' cols='20' name='ta'></TEXTAREA><br><INPUT type='button' value='save' onclick='javascript:alert1(this.form);'><INPUT type='button' value='cancel' onclick='javascript:window.close();'></form></body></html>");
function getValues()
document.forms["source"].elements["srctext"].value = tmp;

<form action="#" name="source" method="get">
<input type="text" onclick='abc();' name="srctext" value="" />

Please help me out in getting the data from parent to pop up window.
Thanks in advance .
Nov 30 '06 #1
1 19081
16,027 Expert Mod 8TB
To pass values from the parent window to the popup window is even simpler. Declare wind1 as a global variable and once you've opened a window using window.open() assigned to wind1, wind1 now contains a reference to the popup window. For example, to access and set the value of the textarea in the popup window:
Expand|Select|Wrap|Line Numbers
  1. wind1.document.forms["myform"].elements["ta"].value = "whatever you want to set it to...";
May 31 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Marco Antonio Montalvo Durán | last post: by
5 posts views Thread by Peter | last post: by
reply views Thread by Peter | last post: by
3 posts views Thread by Aaron | last post: by
1 post views Thread by czuvich | last post: by
1 post views Thread by colleen1980 | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.