By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,940 Members | 1,250 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,940 IT Pros & Developers. It's quick & easy.

Getting action info from popup to main window

P: n/a
I need to have a user be able to click a link or button that brings
up a popup window. When the user selects an item from the drop down
list on the popup window (should I require only a click of the item or
clicking a separate button like "continue"?), I need the selection to
show up in a text field on the main page. Yet, so far as I can tell,
window.open() has no way to return any value. So how can I do this
please? I'm sure it's a common thing to do. I see calendar popups do
this all the time. Thanks.

Ken
Jun 27 '08 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Jun 26, 3:03*pm, DrKen <javaje...@yahoo.comwrote:
* *I need to have a user be able to click a link or button that brings
up a popup window. *When the user selects an item from the drop down
list on the popup window (should I require only a click of the item or
clicking a separate button like "continue"?), I need the selection to
show up in a text field on the main page. *Yet, so far as I can tell,
window.open() has no way to return any value. So how can I do this
please? I'm sure it's a common thing to do. I see calendar popups do
this all the time. *Thanks.

Ken
You can call window.opener.<function_name>.

For example in your parent window you have a method named:

setSelection(selection) {
//do something with selection value...
}

Then in your popup window you can call:

var value = document.getElementById("someID").value;
window.opener.setSelection(value);

HTH.

Jun 27 '08 #2

P: n/a
On Jun 26, 12:06 pm, Tom Cole <tco...@gmail.comwrote:
On Jun 26, 3:03 pm, DrKen <javaje...@yahoo.comwrote:
I need to have a user be able to click a link or button that brings
up a popup window. When the user selects an item from the drop down
list on the popup window (should I require only a click of the item or
clicking a separate button like "continue"?), I need the selection to
show up in a text field on the main page. Yet, so far as I can tell,
window.open() has no way to return any value. So how can I do this
please? I'm sure it's a common thing to do. I see calendar popups do
this all the time. Thanks.
Ken

You can call window.opener.<function_name>.

For example in your parent window you have a method named:

setSelection(selection) {
//do something with selection value...

}

Then in your popup window you can call:

var value = document.getElementById("someID").value;
window.opener.setSelection(value);

HTH.
Thanks. I was about to post an addendum. The main page has three
fields that are essentially identical:
Prior School 1:...................
Prior School 2:...................
Prior School 3:...................

If the person clicks on a button to find the school for the first of
these three, I need to fill in the first of the three. If the person
clicks on the third box's link for the popup, I need to have the third
row populated. Is there a way to do this without having to create
three separate popup windows? Thanks.

Ken
Jun 27 '08 #3

P: n/a
SAM
DrKen a écrit :
>
Thanks. I was about to post an addendum. The main page has three
fields that are essentially identical:
Prior School 1:...................
Prior School 2:...................
Prior School 3:...................

If the person clicks on a button to find the school for the first of
these three, I need to fill in the first of the three. If the person
clicks on the third box's link for the popup, I need to have the third
row populated. Is there a way to do this without having to create
three separate popup windows? Thanks.
certainly, you can send in the same poppup all what you want, info 1 of
school 1, info 3 of scholl 3 etc

function pop(page) {
// if popup doesn't exist or is closed
if(typeof truc == 'undefined' || truc.closed)
truc = window.open('','','width=300,height=400'); // create it
truc.location = page; // load in it the asked file
truc.focus(); // bring it to front
}

In the file loaded in the popup

<form
action="javascript:opener.document.form1.school_2. value=this.choice.value;opener.focus()">
Choose an option for School #2 : <select name="choice">
<option value="1"first
<option value="2"second
</select><input type=submit>
</form>
That would have to work too with tabs
--
sm
Jun 27 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.