Davey wrote:
I have a website which has a popup window (this only opens when the
user chooses to open it). In the popup window I have a <select>
control which lists a selection of "classes". Each class has a
description and a class_id (stored in the value attribute of each
option). The user will then select a class from the drop-down list.
What I want to do is have a control in the parent browser window
which can store the class_id and the description that the user has
selected in the popup window.
Any suggestions as to what control I should use in the parent window
and more importantly how I get the value from the popup window (this
must be client side code as the user will have entered other values
into the form in the parent browser window)?
This has nothing to do with ASP (you coulc be doing all of this with two
..htm pages, so it's not an asp issue). You should follow up in a client-side
scripting newsgroup such as m.p.scripting.jscript.
The specific answer depends on how you are generating the popup window
(openModalDialog? open?). In general, most of these functions return a
handle to the window that is being opened. You can use that handle to refer
to objects in the new window. The new window will also have a reference to
the parent window, either via an argument in the function used by the parent
window to open it, or via its parentWindow property.
The idea is to create what's called a "callback" function in the parent
window. This function can be called by an event procedure (perhaps a
button's onclick event) in the child window. When called it can use the
handle returned by the function used to open the child window to enable it
to read the properties of any controls in the child window and do whatever
you want with them.
The answer to the first question (what control to use in the parent window)
depends on the use to which you want to put the values from the child form.
Maybe a control isn't even needed, as global variables can be used.
Again, follow up in a client-side newsgroup. If you reply to this, please
remove the asp groups from the crosspost.
Bob Barrows
PS. since they are not on the msnews server, I cannot reply to the alt.html
or comp.lang groups in the crosspost, so I am leaving the asp groups in this
post.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.