Hi there,
I'm having trouble creating a new option in a parent window from my child window.
Here's my code...
Parent window
<html>
<head>
<SCRIPT Language="Javascript">
<!--
function myopen(){
window.open'popup.htm','popup','width=250,height=250,status=Yes');
}
//-->
</SCRIPT>
<title>Option test</title>
</head>
<body>
<form action="" method="post" name="form1" id="form1">
<select name="myoption" onChange="myopen();">
<option value="Boy">Boy</option>
<option value="Girl">Girl</option>
<option value="Not Sure">Not Sure</option>
</select>
<br>
<input type="text" name="myresult" value="">
</form>
</body>
</html>
Child Window
<html>
<head>
<title>Untitled</title>
<SCRIPT Language=Javascript>
<!--
function addoption(){
var odoc=opener.window.document.form1
odoc.myresult.value='result!'
odoc.myoption.options[(odoc.myoption.options.length+1)]=new Option('hi','hi')
self.close();
}
//-->
</SCRIPT>
</head>
<body>
<A Href="#" onClick="addoption();">Click ME</A>
</body>
</html>
Now the strange thing is, it works fine if the code is on the same page, but just won't work over two pages, note for a test I used a textbox aswell called myresult, the value gets sent through to this box correctly every time.
Please help if you can.
Cheers,
Alex.
I'm having trouble creating a new option in a parent window from my child window.
Here's my code...
Parent window
<html>
<head>
<SCRIPT Language="Javascript">
<!--
function myopen(){
window.open'popup.htm','popup','width=250,height=250,status=Yes');
}
//-->
</SCRIPT>
<title>Option test</title>
</head>
<body>
<form action="" method="post" name="form1" id="form1">
<select name="myoption" onChange="myopen();">
<option value="Boy">Boy</option>
<option value="Girl">Girl</option>
<option value="Not Sure">Not Sure</option>
</select>
<br>
<input type="text" name="myresult" value="">
</form>
</body>
</html>
Child Window
<html>
<head>
<title>Untitled</title>
<SCRIPT Language=Javascript>
<!--
function addoption(){
var odoc=opener.window.document.form1
odoc.myresult.value='result!'
odoc.myoption.options[(odoc.myoption.options.length+1)]=new Option('hi','hi')
self.close();
}
//-->
</SCRIPT>
</head>
<body>
<A Href="#" onClick="addoption();">Click ME</A>
</body>
</html>
Now the strange thing is, it works fine if the code is on the same page, but just won't work over two pages, note for a test I used a textbox aswell called myresult, the value gets sent through to this box correctly every time.
Please help if you can.
Cheers,
Alex.