June 15, 2005, 03:26 PM
webfocusdevReturning value from pop-up window query to main screen...
Hi,
I'm creating an html search page with numerous parameters. One of them is "Author". What I want to do is have the user click a button next to the Author field which will open a pop-up window. They will be presented with text boxes for Name: and Org:. They will enter their search criteria and click submit. Their results will be returned in a select list. After making a selection, this value will be returned to the main html page and the pop-up window closes. Has anyone created anything similar? Any help would be greatly appreciated.
Thanks...
June 15, 2005, 08:34 PM
mgrackinI have done this before and it is pretty simple. What you need to do is add an action to the html page that contains the select box that performs a "window.opener.document.formname.objectname.value=value_selected_in_the_dropdown;". I assume the popup window is being opened with a "window.open();" command. Use the code pieces below to setup two HTML pages that demonstrate the technique.
Parent Page Code:
Create a parent page that performs an on click method using a input box with a type of button to open a page called popupbox.htm. The parent page should contain a FORM called "FEXTEST" with an INPUT box with the name of "getit".
on click = window.open("popupbox.htm")
PopUpBox Page Code:
<select name=thelist>
<option value="The First One">One</option>
<option value="The Second One">Two</option>
<option value="The Third One">Three</option>
</select>
<INPUT name=submit type=button value="OK"
on click =
"window.opener.document.FEXTEST.getit.value=thelist.value;">
You can also add a self.close(); statement in the on click method so the popupbox page closes after "sending" the value to the parent page.