How can I do this:
Let's say the user selects "Checkbox #1" and "Checkbox #3" in the form below and submit, the values will be passed as "01" and "03", right? How can I do for these values "01" and "03" passed by the form to recognize it's respective local vars shown below to do the sum and print it's values and labels on screen?
I know how to do it with only one value but not with an array. Please help.
HTML Code:
<html><head></head><body>
<form name=f1 method=post action=get_checked.php>
<input name="checkboxes[]" type="checkbox" value="01">Checkbox #1<br>
<input name="checkboxes[]" type="checkbox" value="02">Checkbox #2<br>
<input name="checkboxes[]" type="checkbox" value="03">Checkbox #3<br>
<input name="Submit" type="submit" value="Submit">
</form>
</body></html>
PHP:
<?
// get_checked.php
$checkbox_label_01 = "Book";
$checkbox_price_01 = "5.00";
$checkbox_label_02 = "CD";
$checkbox_price_02 = "8.00";
$checkbox_label_03 = "Games";
$checkbox_price_03 = "5.00";
$count_checked = count($checkboxes);
for ($i=0; $i<$count_checked; $i++) {
echo $checkboxes[$i];
}
?>