A common practice for checkboxes is to pair it with a hidden field, which will ensure that the HTTP post always includes a value even when the checkbox is left unchecked.
For example, if I have a terms checkbox, I might implement it like this, with both the checkbox and a hidden element:
<input type="checkbox" name="termsAgreement" value="true"> I accept the terms.
<input type="hidden" name="termsAgreement" value="false">
When it is posted back, the HTTP request contains either two values (when checked):
termsAgreement=true&termsAgreement=false
Or one value (when not checked):
termsAgreement=false
It's easy to handle this, as you just have to OR
the values either way, and you will get the proper value.
However, if you want to determine the proper value client-side, the only solution I can think of involves some pretty nasty logic.
Is there an elegant way to fairly easily determine the value using JavaScript or jQuery in this case?