I have several groups of checkboxes, each group has unique class name, I would like to select all function for each group. I have a JavaScript function like this:
function toggle(source) {
var checkboxes = document.getElementsByClassName(classname);
for(var i=0, n=checkboxes.length;i<n;i++) {
checkboxes[i].checked = source.checked;
}
}
It works when <INPUT type="checkbox" onClick="toggle(this)" /> and I hard coded class name in javascript function.
I tried:
<INPUT type="checkbox" onClick="toggle(this,<?php echo $key ?>)" />
And change javascript function to function toggle(source, classname){...} and toggle() then use arguments[0] for source, arguments[1] for classname in original function. Neither of them worked.
What is the right way to add parameter to this function?