- What is the value of an unchecked checkbox?
- Can a checkbox have a value?
- How to pass checkbox value 0 if not checked and 1 if checked?
What is the value of an unchecked checkbox?
Note: If a checkbox is unchecked when its form is submitted, there is no value submitted to the server to represent its unchecked state (e.g. value=unchecked ); the value is not submitted to the server at all.
Can a checkbox have a value?
The value attribute on the checkbox is used when the form is interacting with a server. So when you set the value as lettuce, that means when the form is submitted and that box is checked, the value it sends back to the server is topping=lettuce .
How to pass checkbox value 0 if not checked and 1 if checked?
Add a hidden input that has the same name as the checkbox with the value of 0 BEFORE the checkbox. If the checkbox is unchecked, the hidden field value will be used, if it is checked the checkbox value will be used.