>> aCheckBoxes = document.all.group1; D'oh!
that's the key to it - access them as an array by ID. I was too hung-up on getElementById and then trying to put them into an array. thank you Elliot! I suspected there was an easier way to do it... cheers barry.b -----Original Message----- From: Elliot Russo [mailto:[EMAIL PROTECTED] Sent: Wednesday, 14 April 2004 2:55 PM To: CFAussie Mailing List Subject: [cfaussie] Re: (OT) access groups of chkboxes using ID, not name Hi, the array of checkboxe objects is accessible by id as well as name so you can do the following if I understand. All the names are different but ids are shared in groups <table> <tr> <td> <input type="checkbox" name="check1" id="group1"> <br><input type="checkbox" name="check2" id="group1"> <br><input type="checkbox" name="check3" id="group1"> </td> <td> <input type="checkbox" name="check4" id="group2"> <br><input type="checkbox" name="check5" id="group2"> <br><input type="checkbox" name="check6" id="group2"> </td> </tr> </table> <script> aCheckBoxes = document.all.group1; for (var i = 0; i < aCheckBoxes.length; i++) { aCheckBoxes[i].checked = true; } </script> "barry.b" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > hi all > I've got a form with a hundred or so checkboxes. I want to set up small > groups of them to check/uncheck. I can't use the name (form processing, > diff order) so I'm trying to use the ID. > > the bit I'm stuck on is getting an array of checkboxes and then looping > thru them to check only using the ID. I can get the first one to work but > not the other ones of the same name. any ideas? > > thanx > barry.b > > > <script> > function checkAll(id) { > cbox = eval("document.getElementById(id)"); > if (cbox.checked == true){ > cbox.checked = false; > return "Check All"; > }else{ > cbox.checked = true; > return "Uncheck All"; > } > } > </script> > > here's part of the form > > > <td><input type=button value="Check All" onClick="this.value=checkAll('view_ADM')"></td> > <td><input type=button value="Check All" onClick="this.value=checkAll('add_ADM')"></td> > <td><input type=button value="Check All" onClick="this.value=checkAll('edit_ADM')"></td> > <td><input type=button value="Check All" onClick="this.value=checkAll('del_ADM')"></td> > </tr> > <tr> > <td> Menu Admin </td> > <td><input type="Checkbox" name="Perm_b_40 " id="view_ADM" checked></td> > <td><input type="Checkbox" name="Perm_b_37 " id="add_ADM"></td> > <td><input type="Checkbox" name="Perm_b_39 " id="edit_ADM"></td> > <td><input type="Checkbox" name="Perm_b_38 " id="del_ADM"></td> > </tr> > <tr> > <td> Users Admin </td> > <td><input type="Checkbox" name="Perm_b_36 " id="view_ADM" checked></td> > <td><input type="Checkbox" name="Perm_b_33 " id="add_ADM"></td><td><input type="Checkbox" name="Perm_b_35 "id="edit_ADM"></td> > <td><input type="Checkbox" name="Perm_b_34 " id="del_ADM"></td> > </tr> > <tr> > <td> Utilities Admin </td> > <td><input type="Checkbox" name="Perm_b_44 " id="view_ADM" checked></td> > <td><input type="Checkbox" name="Perm_b_41 " id="add_ADM"></td> > <td><input type="Checkbox" name="Perm_b_43 " id="edit_ADM"></td> > </tr> > > --- You are currently subscribed to cfaussie as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED] MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia http://www.mxdu.com/ + 24-25 February, 2004 --- You are currently subscribed to cfaussie as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED] MXDU2004 + Macromedia DevCon AsiaPac + Sydney, Australia http://www.mxdu.com/ + 24-25 February, 2004
