Add this code to the top of the <script> section:
javascript code:
var getCheckboxes = function () {
var i, elements = document.getElementsByTagName("input"),
max = elements.length,
result = [];
for (i = 0; i < max; i += 1) {
if (elements[i].type === "checkbox") {
result.push(elements[i]);
}
}
return result;
};
Then change the line with the error so it reads:
javascript code:
var checkBoxes = getCheckboxes,
If that still doesn't work, post the code you have and I'll see if I can spot the problem.
Btw, the reason it's best to put all your
var declarations at the start of the function is that it helps you get clear in your head what the function needs and does. When you start declaring them inline whenever and wherever, it becomes difficult to remember what does what.