Unknown amount of checkboxes to check
Moderator: General Moderators
Unknown amount of checkboxes to check
Ok, I have a script that has to generate a form, which could have any number of checkboxes, from 1 to idfk. I want to know how I could easilly check which checkboxes are set to "on", and get their ID, when the form is submitted.
Re: Unknown amount of checkboxes to check
Use arrays.
PS: to see which ones were unchecked, figure out what checkboxes were available then "subtract" the ones that were selected.
Code: Select all
<input type="checkbox" name="checkbox[1]">
<input type="checkbox" name="checkbox[2]">
<input type="checkbox" name="checkbox[3]">Code: Select all
$checkboxes = array_keys($_POST["checkbox"]);