Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems sending values from child windows to parent windows

Status
Not open for further replies.

abienz

Programmer
Aug 13, 2001
53
0
0
GB
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=&quot;Javascript&quot;>
<!--
function myopen(){
window.open'popup.htm','popup','width=250,height=250,status=Yes');
}
//-->
</SCRIPT>
<title>Option test</title>
</head>

<body>
<form action=&quot;&quot; method=&quot;post&quot; name=&quot;form1&quot; id=&quot;form1&quot;>
<select name=&quot;myoption&quot; onChange=&quot;myopen();&quot;>
<option value=&quot;Boy&quot;>Boy</option>
<option value=&quot;Girl&quot;>Girl</option>
<option value=&quot;Not Sure&quot;>Not Sure</option>
</select>
<br>
<input type=&quot;text&quot; name=&quot;myresult&quot; value=&quot;&quot;>

</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=&quot;#&quot; onClick=&quot;addoption();&quot;>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.
 
Yes, it happens with some objects. You may use the showModalDialog method passing the form as a argument, example:

Parent Window:

<html>
<head>
<SCRIPT Language=&quot;Javascript&quot;>
<!--
function myopen(){
var z=showModalDialog('popup.htm' , document.form1 , 'center:yes;dialogHeight:250px;dialogWidth:250px;help:no;scroll:no;status:yes');
}
//-->
</SCRIPT>
<title>Option test</title>
</head>
.
.
.

Child Window

<html>
<head>
<title>Untitled</title>
<SCRIPT Language=Javascript>
<!--
function addoption(){
odoc=new Object(window.dialogArguments);
odoc.myresult.value='result!'
.
.
.

Hope this help,

Sergio M. Netto.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top