Answer the question
In order to leave comments, you need to log in
Passing empty checkboxes and "not set" values?
There is a simple checkbox in the form, when filling (it doesn't matter whether it's Ajax or not), an empty value is not transmitted and the key is also ignored. In order not to complicate the task of checking on js or on the backend (many different forms and checkboxes), I add input hidden in front of it with the same name. Thus, if the checkbox is pressed, then it overrides hidden, and if it is not pressed, then hidden sets the default value.
<input type="hidden" name="set" val="N">
<input type="checkbox" name="set" val="Y">
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question