473,837 Members | 1,648 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get value from popup window to parent window

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)?

TIA
Sep 6 '05 #1
4 10495
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.j script.

The specific answer depends on how you are generating the popup window
(openModalDialo g? 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.
Sep 6 '05 #2
"Davey" <da***@hello.co m> wrote in message news:43******** **@x-privat.org...
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)?


The "opener" property of the popup window is a reference to, well, the
opener. ;^) It links the window which opened the popup.

So you might, to populate a form field in the main window, say (from memory
so I may be a bit off):

window.opener.f orms.MainForm.S electedClass.va lue = "Whatever they pick";

If you have a variable called "CurrentCla ss" in the main window you can
populate it from the popup like:

window.opener.C urrentClass = "whuddeva";

"opener" is a top-level element: if your popup or your main caller uses
frames then it might get more complicated (you'd have to chain the reference
out further)... but it's still definitely doable.

Good luck!

Jim Davis
Sep 6 '05 #3
"Jim Davis" <ne********@vbo ston.com> wrote in message
news:df******** *@news2.newsguy .com...
"Davey" <da***@hello.co m> wrote in message
news:43******** **@x-privat.org...
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)?
The "opener" property of the popup window is a reference to, well, the
opener. ;^) It links the window which opened the popup.


What is the syntax for opening a popup which will allow "opener" to be
accessed from the popup?
So you might, to populate a form field in the main window, say (from
memory so I may be a bit off):

window.opener.f orms.MainForm.S electedClass.va lue = "Whatever they pick";
Yeah this is definitely the sort of thing I'm looking for.
If you have a variable called "CurrentCla ss" in the main window you can
populate it from the popup like:
By "variable" do you mean hidden form control?
window.opener.C urrentClass = "whuddeva";

"opener" is a top-level element: if your popup or your main caller uses
frames then it might get more complicated (you'd have to chain the
reference out further)... but it's still definitely doable.


Excellent thanks.
Sep 6 '05 #4
"Davey" <da***@hello.co m> wrote in message news:43******** **@x-privat.org...
"Jim Davis" <ne********@vbo ston.com> wrote in message
news:df******** *@news2.newsguy .com...
"Davey" <da***@hello.co m> wrote in message
news:43******** **@x-privat.org... The "opener" property of the popup window is a reference to, well, the
opener. ;^) It links the window which opened the popup.


What is the syntax for opening a popup which will allow "opener" to be
accessed from the popup?


There isn't any - "opener" is a standard property - it's automatically
populated for any popup.
If you have a variable called "CurrentCla ss" in the main window you can
populate it from the popup like:


By "variable" do you mean hidden form control?


Nope - any variable. If, on your main page, you did:

CurrentClass = "SomeStringILik e";

You could change that value later from the popup by doing

window.opener.C urrentClass = "SomeNewStringI Like";

(Actually you can probably just use "opener" without the "window" but I'm
not sure - I tend to be more specific than JavaScript requires.)

"opener" is just a reference to the window object of the main window (well -
the window that opened the popup) - you can do pretty much ANYTHING you
might do in the main window from the popup using it.

If you want to run a function form the main window you'd use
"opener.myFunct ion();" for example. If you wanted to see the title of the
opener you'd use "opener.documen t.title" and so forth. It's all there and
available.

Jim Davis
Sep 6 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1802
by: Alex Shinn | last post by:
I have a site which uses popup windows as a convenience in filling out forms - you choose some data on the popup, click OK, and it sets data on the parent windows form. This works fine in all major browsers and platforms. However, on Mac IE (OS 9 or 10, all versions), there is one situation where this fails. If the parent window was itself launched as a popup, and the parent window's parent was from a different domain than the popup,...
3
4798
by: MEM | last post by:
Hello, I'd like to refresh the main or top most browser window from a child window. Specifically, child popup A is opened by a main browser window then child popup B is opened from within child popup A. How do i refer to the very first parent window? Visual...
1
3784
by: Marshall Dudley | last post by:
I have an application where in a shopping cart checkout a popup appears which suggests other items that may go with what was ordered with a button to add these items to the cart. When the button in the popup is clicked, the popup should present an added items to cart message, close, and reload the parent window, so the parent will show the new item in the cart. It is all working except the post contents for the parent window are being...
1
2866
by: Bill H | last post by:
I run a dbms application that interfaces with the web. This module creates a frames page with two frames ('main' and 'mwinfoframe'). All communication with the dbms is routed through the 'mwinfoframe' (it's sort of hidden in that it is assigned 1% (so I can view it in IE). I'm having problems with Firefox working properly while both IE 6 and Netscape v7.x work as expected. The following is additional information. A list of reports...
4
22218
by: Davey | last post by:
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...
1
3013
by: ABC | last post by:
I has a parent and a popup lookup ASP.NET Form. Both has javascript. I test the popup window's window.Form1.SelectedProductCode.value has a value. But don't know why the return variable "retvar" has not any value pass from popup? -- Parent Windows Script function DoSelectProductCode() { var selectedstr = "";
5
4403
by: knowdotnet | last post by:
Hi all, Which is the best way to return a value back to the web page from a pop up page? I have a asp.net web application which opens a popup page on a link button click. The Link button is contained in a datagrid column. When i submit the popup page I want a value from the page to be returned to the parent page and is to be updated in a dataset, thereby updating the datagrid. I want the parent page to be refreshed on submitting the pop...
11
1936
by: Patricio | last post by:
Hello all I open a PopUp that receives two variables (values). This PopUp must return a value as well. How can I retrieve this value? Thanks a lot.
4
12600
by: neena | last post by:
Hi I am uing C#.net & using javacript for a popup window. I've a form and there is a button named Categories. When it is clicked, it will open a new window for the selection of categories. When the categories are selected from ListBox ,and the submit button of the popup window is clicked, the category id value should be set in the parent form and the popup window will close. the problem is that the parent window form doesn't get the...
10
11920
by: perhapscwk | last post by:
how to passing value from popup to the parent window as a variable which I can access and process the variable(string) in parent window? such as from popup page, we have var_from_popup="abc", after the popup closed, then from parent window, we can use alert(var_from_popup) and it will show us the "abc"?
0
10583
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10642
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10288
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9420
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7824
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5680
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5863
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4062
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3128
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.