Problem
Check / Uncheck all for checkboxes.
Solution Code
Name all checkboxes in a group with a single name ( checkBoxGroup ) in our case.
Name all checkboxes in a group with a single name ( checkBoxGroup ) in our case.
var checkboxes = document.getElementsByName("checkBoxGroup");
if (masterBox.checked) {
for (var i = 0; i < checkboxes.length; i++) {
checkboxes[i].checked = true;
}
} else {
for (var i = 0; i < checkboxes.length; i++) {
console.log(i)
checkboxes[i].checked = false;
}
}
}