Passing data from child window to parent window
In this blog, i will show you how to pass data from child window to parent window.
1. Create a form in parent window.
<form name="parent" id="parent">
<input type="text" id="test" >
<a onClick=window.open("child.html","TITILE",
"width=850,height=150,status=1,");>open the child window</a>
</form>
2. Create a second window
<form name="child" id="child"> <input type="text" id="test_2" name="test_2" value="YOUR DATA"> <input type="button" id="submit" value="submit" onclick="call_submit();"> </form>
3. Pass data to parent window by javascript
function call_submit()
{
opener.document.parent.test.value=document.child.test_2.value
self.close();
}

















hi sir.. it’s showing “[Object]” on the parent page and a javascript error, “opener.document.parent.test” is null or not an object shows in the child window..
please help..
Hi Alex,
Try this one..
window.opener.document.getElementById(test).value=document.getElementById(test_2).value
Thanks for he code.
There is a mistake in the 2nd section “2. Create a second window”.
The form name should be “child” and not “parent”
Hi Jmlb,
Thanks for notifying mistake. It is fixed.
Thanks
Brijesh Shah
Good one….i got solution from this site. Enjoy programming
Regrads,
BReddy
Im opening a child window and am returning the value from child to parent . I also want to process that value in the parent , i use the location.href to refresh the parent page from the child by which i lose the value on page load . Is there any work around this other than sessions or __doPostBack
Im opening a child window and am returning the value from child to parent . I would also want to process that value in the parent , i use the location.href to refresh the parent page from the child by which i lose the value on page load . Is there any work around this other than sessions or __doPostBack ?