Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get and return results from pop-up window?

Status
Not open for further replies.

twidlar

Programmer
Nov 27, 2009
1
US
Hello. This is my first message here. I am an experienced programmer, Pascal, C, C++. Recently I've written a small Java app, quite a few PHP pages and a little Javascript code.

I know how to open up a new window in JS and fill it with HTML including images from the onload event in BODY. I'd like to have the user fill out a fieldd on a FORM and then pass that back to the main page as a value in an INPUT tag. How do I get the value from the user? I pass it back through return(), right?

Basically I am after an HTML-formatted prompt box.

Thanks.
 

This will get you started. This pops up a window where clicking links in the pop-up causes the main window to go to different pages. It could be modified to call a function in the main window and pass parameters to it.

Kirsle.net | My personal homepage
Code:
perl -e '$|=$i=1;print" oo\n<|>\n_|_";x:sleep$|;print"\b",$i++%2?"/":"_";goto x;'
 
Since javascript is object oriented all you really need to do is reference the appropriate object.

So assuming you want to get the value from an input in your popup into another input in the parent page you would reference the object through its parent:


Code:
<script>
function sendvaluetoparent(){
opener.document.forms.[green]myform[/green].[blue]myinput[/blue].value=document.getElementById('[red]mypopupinput[/red]').value;


}
</script>
<input type="text" name="mypopupinput" id="[red]mypopupinput[/red]">
<input type="submit" name="send" value="Return Value" onClick="sendvaluetoparent();">

Code:
<form name="[green]myform[/green]" ... >
<input type=text name="[blue]myinput[/blue]">
...
</form>




----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Please help, I am in a similar position but in the example i would like to programatically pass the element that I want to populate. Eg I have a calendar that is called 3 time in the master form to update 3 different ids such as birth date, mother birthday etc.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top