Hello all,
I have the following two files, main.php and cb_page.php. Currently the doSubmit() function in cb_page.php does not work because it doesn't like
window.opener.document.getElementById("boxes").value=document.getElementById("boxes").value;
and I don't blame it because I have not set an id called boxes.
main.php:
<html>
<body>
<form action="" name="parentForm" method="POST">
<a href="cb_page.php?numboxes=3"onClick="popup=
window.open('cb_page.php?numboxes=3','PopupPage','height=400,width=700,scrollbars=yes,resizable=yes');
return false" target="_blank">Click Here</a>
<input type="hidden" name="boxes" id="boxes" />
</form>
<?php
if (isset($_POST['boxes'])) {
foreach($_POST['boxes'] as $value) {
echo "Box $value";
echo "<br>";
}
}
else{echo "No selection.";}
?>
</body>
</html>
cb_page.php
<html>
<head>
<script language="javascript"> function doSubmit(){
//set the parent hidden field value
window.opener.document.getElementById("boxes").value=
document.getElementById("boxes").value;
//Submit parent form
window.opener.document.parentForm.submit();
//close this window
self.close(); }
</script>
</head>
<body>
<?php
echo "<form name='form1' method='post' action='main.php' onsubmit='doSubmit()'>";
$numboxes = $_GET['numboxes'];
for($count=0; $count<$numboxes; $count ++)
{
echo "Box $count :<input type=checkbox name=boxes[] value=$count><br>";
}
echo "<input type='submit' name='Submit' value='Submit'>";
echo "</form>";
?>
</body>
</html>
How do I set the id for "boxes"? I tried putting
id="boxes"
into those input checkbox statements, but it didn't work.
Basically, I get the results I want, but in the popup window instead of the original window because doSubmit isn't working so the popup doesn't close.
Thanks so much for your help! (I've wasted way too many days on this already!)
[/COLOR]