[Javascript] turning on checkboxes

Peter Brunone peter at brunone.com
Fri Aug 10 10:48:54 CDT 2001


var i = 0;

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

    When you have multiple radio buttons or checkboxes with the same name,
the JS engine treats them as an array of that name containing each checkbox
as an element in that array.

Cheers,

Peter

----- Original Message -----
From: <susan at plonka.com>
To: <javascript at LaTech.edu>
Sent: Friday, August 10, 2001 9:47 AM
Subject: [Javascript] turning on checkboxes


| I'm trying to figure out how to make a "Select All checkboxes" button
| function.
|
| The checkboxes are generated dynamically in a loop from reading a
| database and their names correspond to the memberID. I don't know how
| many, that's dynamic too.
|
| I want to be able to get the checkbox names and turn them all on with
| this button.
|
| <script language="JavaScript">
| function selectAll() {
| document.members.cb1050.checked = true
| }
| <script>
|
| <body><table> <!--- SQL stuff -->
| <% do while not connMembers.eof %>
| <tr><td>
| <input type="checkbox" name="<%= connMembers(0) %>">
| </td></tr>
| <% connMembers.movenext
| Loop %>
| </table>
|
| <table width="500"><tr><td width="100%" align="center">
| <input type="button" value="Select All" onclick="selectAll()">
| </td></tr></table>
| </body>
|
|
|
| _______________________________________________
| Javascript mailing list
| Javascript at LaTech.edu
| http://www.LaTech.edu/mailman/listinfo/javascript
|




More information about the Javascript mailing list