mtran
12-02-2007, 05:27 AM
I'm not well-versed in PHP but managed to dynamically generated a page/list of items, and their descriptions, images.... including a checkbox before each items. That page - page 1 - is ok.
<form name="compareForm" method="post" action="page2.php">
<?php
[loop]
.....
<input type="checkbox" value="<?php print $id ?>" name="compare[]" />
<a href="javascript:document.compareForm.submit();">Compare</a>
[end loop]
?>
</form>
Viewing source shows that the Value of the checkboxes are generated correctly - which are the Item Ids - 1, 2, 3...
However, if I check some checkboxes and submit the form, the values don't seem to be passed to page 2, which has the following codes:
<?php
$compare = $_POST["compare"];
foreach ($compare as $value) {
print $value."<br />";}
?>
Things that I tried:
- Changed value="<?php print $id ?>" to hard-coded value="123": not work
- Use only one Submit button at the end of the form instead of the Submit links under each item: not work
Did I miss anything? or can we pass dynamically generated checkbox values?
Thanks for the inputs!
<form name="compareForm" method="post" action="page2.php">
<?php
[loop]
.....
<input type="checkbox" value="<?php print $id ?>" name="compare[]" />
<a href="javascript:document.compareForm.submit();">Compare</a>
[end loop]
?>
</form>
Viewing source shows that the Value of the checkboxes are generated correctly - which are the Item Ids - 1, 2, 3...
However, if I check some checkboxes and submit the form, the values don't seem to be passed to page 2, which has the following codes:
<?php
$compare = $_POST["compare"];
foreach ($compare as $value) {
print $value."<br />";}
?>
Things that I tried:
- Changed value="<?php print $id ?>" to hard-coded value="123": not work
- Use only one Submit button at the end of the form instead of the Submit links under each item: not work
Did I miss anything? or can we pass dynamically generated checkbox values?
Thanks for the inputs!