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!
Passing values between windows
Moderator: General Moderators
javascript it is....
sample:
and the child window...
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>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>