[Javascript] Return value from popup

Marsie Welch mjwelch at adelphia.net
Wed Mar 5 15:06:25 CST 2003


I'm trying to create a form that opens a popup and then transfers the value entered in a popup form, back to the form that opened the popup.

I get the error message:
Error: 'document.forms.0.input' is null or not an object


Any help would be appreciated.  Here is my code:

THE SIMPLE "MAIN" FORM

<html>
<head>
<title>Simple Form</title>
</head>
<body>
<script language="JavaScript">
<!--
function windowOpen() {
    var myWindow=window.open('popup.htm','windowRef','width=200,height=200');
    if (!myWindow.opener) myWindow.opener = self;
}
//--></script>
<input name="openPopup" type="button" id="openPopup" onClick="Javascript:windowOpen();" value="Get Value" />
<form name="form1" id="form1" method="post" action="">
    <input type="text" value="" name="output"></input>
</form>
</body>
</html>

THE POPUP FORM (popup.htm)
<html>
<head>
<title>The Popup</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>

<body>
<script language="JavaScript"><!--
function updateOpener() {
    window.opener.document.forms[0].output.value = document.forms[0].input.value;
    window.close();    
}
//-->
</script>
EventId: 
<input type="text" name="input"></input>
<input name="Close" type="submit" id="Close" onClick="Javascript:updateOpener()" value="Close"></input>
</body>
</html>



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20030305/df6f10cc/attachment.htm>


More information about the Javascript mailing list