I have been wrecking my brains trying to figure out why I get an undefined error for the array statusIdValues when I hit the first push in the code below. Its initialised in a ready function and is pushed into when a checkbox state changes.
$(document).ready(function () {
var statusIdValues = [];
$(':checkbox').change(function () {
if ($(this).is(":checked")) {
statusIdValues.push($(this).attr("value"));
}
else {
var index= statusIdValues.indexOf($(this).attr("value"));
if (index > -1) {
statusIdValues.splice(index, 1);
}
});
});
Any help would be appreciated.
array.indexOf($(this).attr("value"));What is array ?