Passing data from child window to parent window

By , July 24, 2009 8:54 pm

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();

}
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Webnews
  • Digg
  • del.icio.us
  • Reddit
  • Bloglines
  • LinkedIn
  • YahooMyWeb
  • Facebook
  • Google Bookmarks
  • Mixx
  • MySpace
  • Technorati
  • TwitThis

7 Responses to “Passing data from child window to parent window”

  1. alex says:

    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..

  2. Brijesh Shah says:

    Hi Alex,

    Try this one..

    window.opener.document.getElementById(test).value=document.getElementById(test_2).value

  3. jmlb says:

    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”

  4. BReddy says:

    Good one….i got solution from this site. Enjoy programming

    Regrads,
    BReddy

  5. ratheesh says:

    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

  6. ratheesh says:

    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 ?

Leave a Reply

*

Panorama Theme by Themocracy