PDA

View Full Version : Disabling Checkboxes


Bobba Buoy
11-12-2005, 11:15 AM
I have written a group email utility that has recipients from 3 groups of people: Partcipants, Assistant Coaches, and Staff Members. I have all recipients
identified by check boxes. For each group there is a "Email All" checkbox. For instance, to email all participants, they would select a check box with the name
all_parts. What I am trying to do is disable all checkboxes from all participants when the all_parts checkbox is selected. I want that to happen with all three groups of recipients. The javascript is below. What it does right now is disables all other checkboxes on the form when the all_parts is selected. How can I do that so only the checkboxes whose name/id/title begin with "part_" are disabled?

Thanks!

function AllParts() {
var numControls = document.grp_email.length;
var boolVal = true;
var element = null;

if (!grp_email.all_parts.checked) {
boolVal = false;
}
for (var aa = 0; aa < numControls; aa++) {
element = document.grp_email[aa];
if ((element.type == "checkbox") && (element.name != "all_parts")) {
element.disabled = boolVal;
if (boolVal) {element.checked = !boolVal;}
}
}
}

function AllStaff() {
var numControls = document.grp_email.length;
var boolVal = true;
var element = null;

if (!grp_email.all_staff.checked) {
boolVal = false;
}
for (var aa = 0; aa < numControls; aa++) {
element = document.grp_email[aa];
if ((element.type == "checkbox") && (element.name != "all_staff")) {
element.disabled = boolVal;
if (boolVal) {element.checked = !boolVal;}
}
}
}

function AllAssts() {
var numControls = document.grp_email.length;
var boolVal = true;
var element = null;

if (!grp_email.all_assts.checked) {
boolVal = false;
}
for (var aa = 0; aa < numControls; aa++) {
element = document.grp_email[aa];
if ((element.type == "checkbox") && (element.name != "all_assts")) {
element.disabled = boolVal;
if (boolVal) {element.checked = !boolVal;}
}
}
}