Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q78 How can I pass the entered values on a form in a popup window to a form on the original window?

You are here: irt.org | FAQ | JavaScript | Form | 10.3 | Q78 [ previous next ]

The following has been tested in Netscape Navigator 2.02, Netscape Navigator 3, Netscape Navigator 4.02 and Internet Explorer 4pr1 - it might not work in Internet Explorer 3.02.

Contents of doc1.html:

<script language="JavaScript"><!--
function newWindow(file,window) {
    msgWindow=open(file,window,'resizable=no,width=200,height=400');
    if (msgWindow.opener == null) msgWindow.opener = self;
}
//--></script>

<form name="outputForm1">
<input type="button" value="Open doc2.html into window2" onClick="newWindow('doc2.html','window2')">
<br><input name="outputField1" type="text" value="">
<br><input name="outputField2" type="text" value="">
</form>

Contents of doc2.html:

<script language="JavaScript"><!--
function setForm() {
    opener.document.outputForm1.outputField1.value = document.inputForm1.inputField1.value;
    opener.document.outputForm1.outputField2.value = document.inputForm1.inputField2.value;
    self.close();
    return false;
}
//--></script>

<form name="inputForm1" onSubmit="return setForm();">
<br><input name="inputField1" type="text" value="">
<br><input name="inputField2" type="text" value="">
<br><input type="submit" value="Update opener">
</form> 

Feedback on 'Q78 How can I pass the entered values on a form in a popup window to a form on the original window?'

©2018 Martin Webb