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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

check box element, reference all in onClick 1

Status
Not open for further replies.

onressy

Programmer
Mar 7, 2006
421
CA
In a submit button i'm using onClick to call a function to check all check boxes

the check box are dynamic in nnumber like so:
Code:
<input type="checkbox" name="<%=RS2("id")%>" value="<%=RS2("id")%>">

How can i reference dynamic check boxs in the onClick,
this is what i have so far:
onClick="checkAll(document.form1)"




 
loop through all the checkboxes in the form, except the "check all" checkbox, and check them all.

something like...

Code:
function checkAll(f,avoid) {
    var e = f.elements;
    for ( var i = 0; i < e.length; i++ ) {
        if ( e[i].type == 'checkbox' && e[i].name != avoid )
            e[i].checked = true;
    }
}

you'd call it like this:

Code:
<input type="checkbox" name="blah" onclick="if(this.checked) checkAll(this.form,this.name);" />



*cLFlaVA
----------------------------
[tt]"quote goes here"[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Thanks, had to use document ionstead of this:
checkAll(document.form,this.name);"

cheers!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top