[Javascript] radio button, check box check all or none

Peter Brunone peter at brunone.com
Fri May 10 17:26:39 CDT 2002


	Here's the basic syntax:

function selectAll() {
    var i = 0;

    while(i<document.myForm.checkBoxID.length) {
        document.myForm.checkBoxID[i].checked = true;
        i++;
        }
    }

	To uncheck everything, you'd set them = false instead of true.  Trigger it
from anything with an onClick event (button, checkbox, link, etc).

Cheers,

Peter

|-----Original Message-----
|From: javascript-admin at LaTech.edu [mailto:javascript-admin at LaTech.edu]On
|Behalf Of dont worry
|
|I have because by default radio buttons can't be
|"unchecked" I will use checkboxes, but i need
|javascript that will check ALL the checkboxes with the
|same id.  If I have 3 checkboxes with the same Id when
|any one is checked all should get checked.
|Thanks
|




More information about the Javascript mailing list