I have a list of checkboxes and want to return their values on submit. I can do this easily for the checked ones, but not for the unchecked? Here's my code so far:
<input type="checkbox" checked="checked" name="addressBooks[]" value="<?php echo $id; ?>">
<?php
if (isset($_POST['submit'])) {
address_books();
}
function address_books() {
$book = $_POST['addressBooks'];
if (!isset($book)) {
$N = count($book);
echo("You did not select $N book(s): ");
for ($i = 0; $i < $N; $i++) {
echo($book[$i] . " ");
}
} else {
$N = count($book);
echo("You selected $N book(s): ");
for ($i = 0; $i < $N; $i++) {
echo($book[$i] . " ");
}
}
}
Aucun commentaire:
Enregistrer un commentaire