I have three checkboxes with common name
<input type="checkbox" name="checkBox[]" id="checkBox" value="1">
<input type="checkbox" name="checkBox[]" id="checkBox" value="2">
<input type="checkbox" name="checkBox[]" id="checkBox" value="3">
And jquery to push the selected checkbox value into an array before I pass that array to ajax
var data = {'checkBox[]': []};
$(":checked").each(function ()
{
data['checkBox[]'].push($(this).val());
});
I am able to iterate through the checkBox array in PHP in the Ajax page but failing on the client side.
checkBox.length is not giving me the number of checkboxes I've checked. I am unable to find out whether an array is an empty array. I have tried - if (checkBox === undefined || checkBox.length == 0) but got no result. How can I find the length for the above array and whether it is an empty array. I do not want to pass an empty array to the ajax url.
idvalues, or just omit theid. Ids are supposed to be unique across a page.