checkbox - check/uncheck All

wxdqz

New Member
Hi all,

I want to have a check/uncheck All checkbox for 10 checkboxes named ca1,. ca2,.. ca3 ..etc.

function checkAll() {
for (var j = 0; j <= 9; j++) {
box = eval("document.input.CarMaker" + j);
if (box.checked == false) box.checked = true;
}
}

function uncheckAll() {
for (var j = 0; j <= 9; j++) {
box = eval("document.input.CarMaker" + j);
if (box.checked == true) box.checked = false;
}
}


How do call these functions from a checkbox?
I now have two buttons that use: onClick="checkAll()"
and onClick="uncheckAll()" events.
I want to do away with the buttons and just use a single checkbox that toggle between the CheckedAll and UncheckAll, but I don't know how to do this.
Your help is much appreciated.

Thanks,

-Alon.
 
Back
Top