I have a function that is not picking up checkboxes correctly (if checked) with this function:
function playerJson() {
players = [];
$('input[name=playerCheckList]').each(function () {
if ($(this).checked) {
players.push($(this).val());
}
});
return $.toJSON(players);
}
I use this function to check all buttons (correctly)
$(function () {
$("#checkAllPlayers").click(function () {
$('input[name=playerCheckList]').each(function () {
$(this).prop('checked', true);
});
});
});
If I don't have the if statement:
if ($(this).checked)
from the first piece of code, it correctly picks up all the values (checked or not)
So, this statement is probably the problem, but I'm not sure why.
Thanks