Unchecked checkbox returning null value

后端 未结 5 1111
生来不讨喜
生来不讨喜 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:18

    CHANGE YOUR SCRIPT LIKE THIS. HOPE IT HELPS.

    $(document).ready(function(){
        $('#cb1, #cb2, #cb3, #cb4').click(function(){
            $(this).val(this.checked ? 1 : 0);
        });
    });
    

提交回复
热议问题