Getting action info from popup to main window

D

DrKen

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
 
T

Tom Cole

   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.
 
D

DrKen

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
 
S

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:eek:pener.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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,017
Latest member
GreenAcreCBDGummiesReview

Latest Threads

Top