value from child window to parent window in javascript pop up page ...
entered value from child window to parent window
From a child window or a small window once opened, we can transfer any user entered value to main or parent window by using JavaScript. You can see the demo of this here. Here the parent window is known as opener. So the value we enter in a child window we can pass to main by using opener.document object model. So if the name of the form in parent window is f1 and the text box where we want the value to be passed is p_name ( in parent window ) then from the child window we can access them by using the object.opener.document.f1.p_name
The value for this object can be assigned like thisopener.document.f1.p_name.value="Any value";
opener.document.f1.p_name.value = document.frm.c_name.value;
We will keep this line inside a function and call this function on click of a button. Inside the function after executing the above line we will add the code to close the child window. Like this ..
opener.document.f1.p_name.value = document.frm.c_name.value;
self.close();
Here is the demo, Click the button ( take care of popup blocker of your
browser ) and enter your name in child window opened. Then once closed
it will be available at parent window.
To open the child window this is the code used in parent window
No comments:
Post a Comment