Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I check all the checkbox controls in some page? 1

Status
Not open for further replies.

anotherday

Programmer
Jan 17, 2001
9
0
0
AE
I have an unknown number of checkbox controls, and I have a button control. All I need is to check all the checkbox controls when I click the button control.

Thanx.
 
then you want to loop through them all and set their checked attribute to true...to do this you would need to number them, and access throught document.formName[] array.

You could make them radio buttons, and access them thru their own array if you wish.

Or you could go thru the entire form, asking each element what it's type is, and if it returns checkbox, set the value for checked.

for(var j = 0;j<document.formName.elements.length;j++){

if(document.formName.elements[j].type == 'checkbox'){
document.formName.elements[j].checked=true;

}
&quot;Alright whatever man, I'll hook up the hair, but I aint touchin the ring...Cause I'm still a pla--yer&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top