This browser does not support basic Web standards, preventing the display of our site's intended design. May we suggest that you upgrade your browser?

Web Development Code Library JavaScriptSend data from child to parent window

Send data from child to parent window

Use a child popup window to fill in fields on your parent window with this simple code example. This code has not been validated and should be used only as a reference.

Everything you need should be here.
This example opens a popup window with a list of objects on it. When you
click the object, it sends the value back to the parent window's text box.
This works great for pick lists and other applications.




------------------- CUT HERE for PAGE ONE... call it FORM.HTML -----------
<HTML>
<HEAD>

<TITLE>Get Data from Popup Window</TITLE>

<script language="javascript">

function cmdOpenWindow()
{

window.open('dialog.html','DialogWindow');


}

</script>
</HEAD>
<BODY>

<form name="frmMain" method="post" action="form.asp">

<input type="text" name="txtReturnedValue">
<input type="button" value="Get Value" onClick="cmdOpenWindow()">
</form>

</BODY>
</HTML>

------------------------- STOP CUTTING -------------------------


------------------- CUT HERE for PAGE TWO... call it DIALOG.HTML -----------

<HTML>
<HEAD>

<TITLE>Pop-up Pick List</TITLE>


<script language="javascript">

function ReturnValue(strValue)
{

window.opener.document.frmMain.txtReturnedValue.value = strValue;
window.close();

}


</script>
</HEAD>
<BODY>

<form>

<input type="radio" name="list" onclick="ReturnValue('Homer Simpson')">Homer Simpson</input><br>
<input type="radio" name="list" onclick="ReturnValue('Ned Flanders')">Ned Flanders</input><br>
<input type="radio" name="list" onclick="ReturnValue('Montgomery Burns')">Montgomery Burns</input><br>
<input type="radio" name="list" onclick="ReturnValue('Seymore Skinner')">Seymore Skinner</input><br>

</form>

</BODY>
</HTML>
Excellence. Our Measure. Our Motto. Our Goal.