Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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

irt.org | Knowledge Base | JavaScript | Form 10.3 | Q78 [ previous next ]

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

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?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.