I am getting some data using POST in PHP. When checkboxes are checked, there is no problem, but when if one of the rows have an unchecked checkbox, all order of checkboxes are gone. I tried to print array and I see that if a checkbox is unchecked, its value is not written.
For example if I have 5 rows and I check 2 of them. The size of this array is 2 instead of 5. How can I convert unchecked checkboxes into “0” value?
<input onchange="saveChanges();" type="checkbox" name="showS[]" value="1">
You can do several things.
One is to actually show what is checked by doing this:
You could also just use unique identifiers and not an array ofcourse. Another options is to do the difference with the value, not the name.