| Intro Passing Data | Name & Value Muliple Elements | Variable & Value | Data to Popup Data from Popup | OpenerArrays | Form Method |
The following references a popup and its document and the opener from the popup
In the parent page
<script type="text/javascript">
<!--
myPopup=null
function passData1() {
if(myPopup&&myPopup.open&&!myPopup.closed){ // if the popup is already open
myPopup.focus() // refocus popup
return
}
else{ // open popup
myPopup=window.open('p_data3c.htm','win1','left=300,top=100,width=300,height=300')
}
}
function passData2() {
if(myPopup&&myPopup.open&&!myPopup.closed){ // if the popup is open
myPopup.document.popform.textfield1.value=document.openerform.textfield1.value
myPopup.document.popform.textfield2.value=document.openerform.textfield2.value
myPopup.focus()
}
else{
alert("Please open the popup window")
}
}
//-->
</script>
<form name="openerform">
<input type="text" name="textfield1" value="Hello"><BR>
<input type="text" name="textfield2" value="World"><BR>
<input type="button" value="Open Popup" onclick="passData1()">
<input type="button" value="Pass To Popup" onclick="passData2()">
</form>
In the popup page(page2.htm)
<script type="text/javascript">
<!--
function passData() {
opener.document.openerform.textfield1.value=document.popform.textfield1.value
opener.document.openerform.textfield2.value=document.popform.textfield2.value
}
//-->
</script>
<form name="popform">
<input type="text" name="textfield1" value="Popup"><BR>
<input type="text" name="textfield2" value="Acquired"><BR>
<input type="button" value="Pass Data" onclick="passData()">
</form>