Possible Duplicate:
Post the checkboxes that are unchecked
I’ve got a problem with serializing empty array inputs. for example:
<input type="checkbox" name="test_checkbox[]" value="test" id="test">
<input type="checkbox" name="test_checkbox[]" value="test1" id="test1">
<input type="checkbox" name="test_checkbox[]" value="test2" id="test2">
when none of these are checked and I submit the form (via POST), jQuery.serialize() excludes them and they do not appear in my $_POST/Serialized String.
But I need something like test_checkbox=0, when none is ticked.
How can I do that?
Simply inserting this in your server code
Would leave you with the
$_POST['test_checkbox']variable set to 0 if none of them was set by the client. I’d recommend using a new variable instead of resetting the entry in$_POST, though.