passing checkbox values from a popup to a parent
Posted: Tue Apr 29, 2008 7:32 pm
Be gentle-- I am brand new at php and I'm sorry if I am asking a stupid question. I have been searching for a solution to my problem for 3 weeks.
In that time I have found several discussions on this topic but I still can't get it to work.
I have included code. On one page (test.php), I define a variable called "mynumber". There is a link which opens a popup (test1.php) and that number is displayed in the popup window. So, I am sending info successfully in one direction. On test1.php there are checkboxes and a text box. After filling in info there and clicking "Submit" I return to the original page (test.php) and display the text that was typed in the input box. So, I am successfully sending some info back as well.
However, I can not seem to get the checkbox info from test1.php back to test.php.
Thanks in advance for any help!
test.php:
test1.php:
I have included code. On one page (test.php), I define a variable called "mynumber". There is a link which opens a popup (test1.php) and that number is displayed in the popup window. So, I am sending info successfully in one direction. On test1.php there are checkboxes and a text box. After filling in info there and clicking "Submit" I return to the original page (test.php) and display the text that was typed in the input box. So, I am successfully sending some info back as well.
However, I can not seem to get the checkbox info from test1.php back to test.php.
Thanks in advance for any help!
test.php:
Code: Select all
<html>
<head>
<title>test</title>
<script language="javascript" type="text/javascript">
<!--
function popitup(url) {
newwindow=window.open(url,'name','height=400,width=450');
if (window.focus) {newwindow.focus()}
return false;
}
// -->
</script>
</head>
<body>
<form action="test.php" name="parentForm" method="POST">
<a href="test1.php?mynumber=50" onClick="popup = window.open('test1.php?mynumbe\
r=50', 'PopupPage', 'height=400,width=700,scrollbars=yes,resizable=yes'); retur\
n false" target="_blank">Click Here</a>
<input type="hidden" name="txt1" id="txt1" />
<input type="hidden" name="boxes" id="boxes" />
<!--this field will hold the child from value for textbox txt1-->
</form>
<?php
if($_POST){
print_r($_POST);
}
?>
</body>
</html>
test1.php:
Code: Select all
<html>
<head>
<script language="javascript"> function doSubmit(){
//set the parent hidden field value
window.opener.document.getElementById("txt1").value=
document.getElementById("txt1").value;
//Submit parent form
window.opener.document.parentForm.submit();
//close this window
self.close(); }
</script>
</head>
<body>
<?php
$mynumber = $_GET['mynumber'];
echo $mynumber;
?>
<form action="test.php" method="post" name="childForm"
onsubmit="doSubmit()">
Box1:<input type="checkbox" name="boxes[]" value="Box1"><br />
Box2:<input type="checkbox" name="boxes[]" value="Box2"><br />
Box3:<input type="checkbox" name="boxes[]" value="Box3"><br />
<input type="text" name="txt1" id="txt1"> <input type="submit"
name="submit" value="Submit">
</form>
</body>
</html>