Forum Moderators: coopster
In summation: I can get the value of EVERY checkbox, but I only want the ones that were checked. This is my code that gets the value of every checkbox:
$result = count($_POST["id"]);
print "$result in the array\n";
for ($i=0; $i < $result; $i++) {
print $_POST["id"][$i]."\n";
}
I'm coding it like this.
<input name="mycheckbox[10]" type="checkbox" /> - assume it is checked
<input name="mycheckbox[20]" type="checkbox" /> - assume it is NOT checked
<input name="mycheckbox[25]" type="checkbox" /> - assume it is checked
PHP:
$checked = $_POST['mycheckbox'];
foreach($checked as $item) {
echo "Item $item was checked<br />";
}
Output would be:
Item 10 was checked
Item 25 was checked