How would I change this JS function to only check the checkboxes with a value in a comma separated string? With MySQL I can do this using the "IN" function, is there a function like that in Javascript? Cannot seem to find..
I want to select a "Group" Checkbox with a value of 1,2,3,4,5...... and when checked, check the "individual" checkbox below with a single value of 1....or...2....or....3....etc.
Example:
(Checkbox 1) Group 1 Value="1,2,3"
(Checkbox 2) Item 1 Value="1"
(Checkbox 3) Item 2 Value="2"
(Checkbox 4) Item 3 Value="3"
(Checkbox 5) Item 4 Value="4"
So if checkbox 1 is checked, checkboxes 2,3,4 would be checked.
function SetAllCheckBoxes(FormName, FieldName, CheckValue) {
if (!document.forms[FormName]) return;
var objCheckBoxes = document.forms[FormName].elements[FieldName];
if (!objCheckBoxes) return;
var countCheckBoxes = objCheckBoxes.length;
if (!countCheckBoxes) {
objCheckBoxes.checked = CheckValue;
}
else {
// set the check value for all check boxes
for(var i = 0; i < countCheckBoxes; i++) {
objCheckBoxes[i].checked = CheckValue;
}
}
}