There are 3(I do not know how many would be it changeable. 3 only example) checkboxes in my form and I want to detect unchecked checkboxes with php when it post. How can I do this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Gumbo is right. There is a work around however, and that is the following:
In other words: have a hidden field with the same name as the checkbox and a value that represents the unchecked state,
0for instance. It is, however, important to have the hidden field precede the checkbox in the form. Otherwise the hidden field’s value will override the checkbox value when posted to the backend, if the checkbox was checked.Another way to keep track of this is to have a list of possible checkboxes in the back-end (and even populate the form in the back-end with that list, for instance). Something like the following should give you an idea:
… check one or two checkboxes, then click the submit button and see what happens.