How To Send All Checkboxes In Post?
Solution 1:
Only checked checkboxes are sent. A common strategy is to set hidden inputs with the same name and the default unchecked value. Just make sure the checkbox input comes after the hidden input:
<inputtype="hidden" name="cb" value="0">
<inputtype="checkbox" name="cb" value="1">
Then there will always be a $_POST['cb']
with value 0
for not checked and value 1
for checked.
Solution 2:
As I already stated in a comment, the browser will only send the checked checkboxes and will never send all checkboxes. What you can do is to check with PHP if the checkbox is present in the $_POST
or $_GET
variable and act according to the present state.
If you dynamically generate the checkboxes with a PHP script, you can make a hidden box with a serialized array with all the checkbox names to check and then you can only loop through it and check their states later on in the validation script.
Since you didn't provide any code I can't help you with it or make any improvements.
Post a Comment for "How To Send All Checkboxes In Post?"