Page 1 of 1

Passing values between windows

Posted: Wed Nov 23, 2005 2:35 pm
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!

Posted: Wed Nov 23, 2005 3:25 pm
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>

Posted: Wed Nov 23, 2005 3:28 pm
by denz
wonderful! Thank you very much