By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,377 Members | 1,659 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,377 IT Pros & Developers. It's quick & easy.

Pass values between parent and popup window

P: 1

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 ='', '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
Share this Question
Share on Google+
1 Reply

Expert Mod 15k+
P: 16,027
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 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.