Passing values between windows

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
denz
Forum Newbie
Posts: 18
Joined: Fri Jun 24, 2005 4:18 pm

Passing values between windows

Post by denz »

Hi All!

I need to be able to pass a value between 2 windows, so for example, your filling out a form then you need to select something for one of the fields, so you click a button another window fires up and you can make your selection... how would i get that variable to pass back to my original page?

I'm sure it has something to do with Javascript, but i've search and searched and cannot find anything...

thanks for your help!
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

javascript it is....

sample:

Code: Select all

<!-- this is parent page -->
<script>
function childWindow()
{
  var smallwin = window.open('yoursmallwin.php','smwin','width=400,height=400');
  smallwin.focus();
}
</script>

<form name="MyForm">
<input type="text" name="myText"><br>
<input type="button" value="open it" onClick="childWindow()">
</form>
and the child window...

Code: Select all

<script>
function updateParent()
{
  opener.document.MyForm.myText.value = document.MyForm.myText.value;
}
</script>

<form name="MyForm">
<input type="text" name="myText"><br>
<input type="button" value="update parent" onClick="updateParent()">
</form>
denz
Forum Newbie
Posts: 18
Joined: Fri Jun 24, 2005 4:18 pm

Post by denz »

wonderful! Thank you very much
Post Reply