View Full Version : How to Insert values from parent page?

07-10-2002, 09:10 PM
I have a bit of a "chicken or the egg" dilema I think...

I open a new window and I want a <SELECT> object (named "newList") to be populated with values from a like <SELECT> object in the parent page.

<body onload="initialize(this.form)">; (in the newly created window) doesn't work. I get a message that "newList is null or is not an object."

I think that at the point the initialize(this.form) function is triggered, the form containing the <SELECT> object hasn't been loaded / built yet - or at least the <SELECT> object itself does not yet exist.

07-10-2002, 10:08 PM
Well, first of all, if the new pop up window that you're making is just for showing the items of that <Select> tag, then it's better that you do the following:

1- Open your new window in the parent window by typing
something like : newWin = window.open("Z.html","");
2- Then write :
newWin.document.write("<body onload=initialize(" +
this.form + ")>")

But if they're some other things already written in your new page, and you don't want to destroy them by using document.write in the parent page, use "window.opener" in the new window:

<body onload=initialize(window.opener.this.form)>

it should work!

You can also use frames! it's really easier, u define everything that you'll need later to be used in child frames in the main page, then you can easily refer to all of them by top.NameOfYourElement. You won't have the chicken or the egg problem any more!

07-16-2002, 06:39 PM
The mystery is solv'ed. The answer is on this thread: