I'm assuming that what you want is to have a single check-box that allows
the user to select all in that group.

If so, the easiest way to do that would be to wrap the group up inside a
block level element. You can then retrieve the block level object and loop
over it's children checking all elments that are checkboxes.

Something like this:

<script>
function updateBoxes(src) {
        fieldset = src.nextSibling.nextSibling;
        for (i=0;i<fieldset.childNodes.length;i++) {
                thisNode = fieldset.childNodes[i];
                if (thisNode.tagName == 'INPUT' 
                        && thisNode.getAttribute('type').toLowerCase() ==
'checkbox') {
                        thisNode.checked = src.checked;
                }
        }
}
</script>

<input type="checkbox" onClick="updateBoxes(this)"> Select All
<fieldset>
<input type="checkbox" name="foo"> Foo
<input type="checkbox" name="foobar"> Bar
<input type="checkbox" name="foo"> Foo
</fieldset>

Spike

>-----Original Message-----
>From: [EMAIL PROTECTED] 
>[mailto:[EMAIL PROTECTED] On Behalf Of 
>Barry Beattie
>Sent: Tuesday, April 13, 2004 3:58 PM
>To: CFAussie Mailing List
>Subject: [cfaussie] Re: (OT) access groups of chkboxes using 
>ID, not n ame
>
>'fraid not
>
>they already have their own index naming system that the form 
>processing logic depends on. that's why the ID stuff.
>
>b
>
>
>
>-----Original Message-----
>From: KNOTT, Brian [mailto:[EMAIL PROTECTED]
>Sent: Wednesday, 14 April 2004 9:51 AM
>To: CFAussie Mailing List
>Subject: [cfaussie] Re: (OT) access groups of chkboxes using 
>ID, not n ame
>
>How are you generating the field names.  maybe you can name 
>them according to there group and then use javascript to 
>search for the group name in the name field.  i.e. call fields 
>names like menu-1, menu-2, menu-3,users-1,users-2,etc..
>
>Brian
>
>> -----Original Message-----
>> From:        Barry Beattie [SMTP:[EMAIL PROTECTED]
>> Sent:        Wednesday, 14 April 2004 9:40
>> To:  CFAussie Mailing List
>> Subject:     [cfaussie] Re: (OT) access groups of chkboxes using ID,
>not
>> n ame
>> 
>> >> Are you trying to check all checkboxes in the same group.
>> 
>> aye.
>> 
>> the hundred or so are broken up into about 20 groups, depending on a 
>> particular "code group" they belong to which is what I'm setting the
>ID
>> to since I can't change the names.
>> 
>> it's this grouping I need to access to turn them on and off.
>> 
>> 
>> cheers
>> barry.b
>> 
>> 
>> 
>> -----Original Message-----
>> From: KNOTT, Brian [mailto:[EMAIL PROTECTED]
>> Sent: Wednesday, 14 April 2004 9:32 AM
>> To: CFAussie Mailing List
>> Subject: [cfaussie] Re: (OT) access groups of chkboxes using 
>ID, not n 
>> ame
>> 
>> Barry,
>>      Just trying to understand what you are trying to do.  
>Are you trying 
>> to check all checkboxes in the same group.
>> 
>> Brian
>> 
>> > -----Original Message-----
>> > From:      Barry Beattie [SMTP:[EMAIL PROTECTED]
>> > Sent:      Wednesday, 14 April 2004 9:13
>> > To:        CFAussie Mailing List
>> > Subject:   [cfaussie] Re: (OT) access groups of chkboxes using ID,
>> not
>> > name
>> > 
>> > 
>> > >> If there is only one checkbox with the same name
>> > 
>> > but I can't use name at all - that's the problem. 
>> > 
>> > The names of the checkboxes are used for form processing and have 
>> > nothing to do with the groups they need to be checked or unchecked.
>> > 
>> > so that leaves using the ID only. The trouble is that 
>getElementByID 
>> > needs unique ID's to work - that's why only the first one in each
>> series
>> > behaves correctly. The others just sit there.
>> > 
>> > I'm starting to think it can't be done...
>> > 
>> > thanx anyway
>> > barry.b
>> > 
>> > 
>> > -----Original Message-----
>> > From: Australia1976 [mailto:[EMAIL PROTECTED]
>> > Sent: Wednesday, 14 April 2004 8:53 AM
>> > To: CFAussie Mailing List
>> > Subject: [cfaussie] Re: (OT) access groups of chkboxes 
>using ID, not 
>> > name
>> > 
>> > If there is only one checkbox with the same name, you can use 
>> > cbox.checked
>> > 
>> > If there is more than one, you use array notation:
>> > 
>> > cbox[0].checked
>> > cbox[1].checked
>> > cbox[n].checked
>> > 
>> > ----- Original Message -----
>> > From: "barry.b" <[EMAIL PROTECTED]>
>> > To: "CFAussie Mailing List" <[EMAIL PROTECTED]>
>> > Sent: Wednesday, April 14, 2004 1:31 AM
>> > Subject: [cfaussie] (OT) access groups of chkboxes using ID, not
>name
>> > 
>> > 
>> > > 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
>> > 
>> > 
>> > ---
>> > 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
>> 
>> 
>>
>---------------------------------------------------------------
>---------
>> -----------
>> 
>> The contents of this message are the views of the Author and do not 
>> necessarily reflect the views of SUNCORP METWAY LTD  ABN 66 010 831
>722.
>> 
>> 
>> The content of this e-mail, including attachments is a confidential 
>> communication between the Suncorp Metway Group and the intended 
>> addressee. Any unauthorised use of the contents is expressly
>prohibited.
>> If you have received this e-mail in error please contact the sender 
>> immediately and then delete the message and any attachment(s).
>> 
>> http://www.suncorp.com.au
>> 
>> 
>> ---
>> 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
>
>---
>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


---
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

Reply via email to