I was also faced that problem the unchecked checkboxes cannot submit the data when submit form, so I decided to a write a jquery,
here is my html
<input type="checkbox" value="1" checked="checked" named="checked_checkbox" /> <input type="checkbox" value="1" named="un_checked_checkbox" />
When I using print_r($_POST) ;
its just return
Array ( ['checked_checkbox'] = 1 )
and here is #jQuery code to show both unchecked and checked checkboxes
$("form").submit(function () { //WHEN FORM WILL SUBMIT var this_master = $(this); this_master.find('input[type="checkbox"]').each( function () { var checkbox_this = $(this); //CREATE VARIABLE OF CHECKBOX_THIS if( checkbox_this.is(":checked") == false ) { checkbox_this.prop('checked',true); //ITS JUST CHECK THE CHECKBOX TO SUBMIT FORM DATA checkbox_this.attr('value','0'); } }) })
now I have check the result of form data with print_r($_POST); the above #jQuery function will return checked value =1 and un-checked value return 0
Array ( ['checked_checkbox'] = 1 ['un_checked_checkbox'] = 0 )