Unchecked checkbox returning null value

后端 未结 5 1109
生来不讨喜
生来不讨喜 2020-12-09 05:23

I have a set of checkboxes which when checked they pass the value as 1, otherwise they pass the value as 0. However, instead of sending the value of the unchecked checkboxe

5条回答
  •  离开以前
    2020-12-09 06:17

    With jQuery you could use the checked selector to get the state of a checkbox. When it is checked, the length contains something greater than 0, e.G.:

    $('#id:checked').length
    

    So you don't need to set the value of the checkbox element to 0...

提交回复
热议问题