I\'m really bad at Javascript and I\'m struggling to get my head round it.
What I\'m trying to do is get something to select all checkboxes. However everything I have fo
Pseudo code:
function checkAll(array_with_id_values)
{
for (var i = 0, ilen = array_with_id_values.length; i < ilen; i++)
{
document.getElementById(array_with_id_values[i]).checked = true;
}
}
Call it with:
checkAll(['my-unique-id', 'my-other-unique-id', 'my-third-unique-id']);
You should ofc not use such verbose variable names and do checks that the argument is an array and that the element you get is a checkbox etc etc.
JQuery is great when there's a pattern to match. See Check All Checkboxes with JQuery.