<input type="checkbox" id="mark_box0" name="mark_box[]">
<input type="checkbox" id="mark_box1" name="mark_box[]">
<input type="checkbox" id="mark_box2" name="mark_box[]">
I want to get the checked and not checked check boxes in a array. Please refer the sample output array below.
Array
(
[0] => 1 //mark_box0 is checked
[1] => 0 //mark_box1 is not checked
[2] => 1 //mark_box2 is checked
)
I tried some code but not working correctly
var is_checked = $("input[name='mark_box[]']").map(function(){return this.value;}).get();
above code returns below array whenever checked or not
Array
(
[0] => on
[1] => on
[2] => on
)
var is_checked = $("input[name=mark_box]:checked").map(function() {
return this.value;
}).get().join(",")); // returns empty array
Please help me to do this.