How can I modify this example so it can get values from checkboxes that aren\'t checked?
I want all checkboxes to have a value, if it hasn\'t been checked I want to get
you can add a hidden false value for every checkbox:
You will only get "false" values for unchecked checkboxes and both "true" and "false" for checked checkboxes, so you can remove the duplicates like this:
var params = {};
$.each($('form').serializeArray(), function (index, value) {
params[value.name] = params[value.name] ? params[value.name] || value.value : value.value;
});
console.log(params); // outputs: {"Check01":"false","Check02":"true"}