I use... $$('.class').each(function(element) { if(element.checked==true) { // do somehting with the element or its value } });
there might be a better way Alex Mcauley http://www.thevacancymarket.com ----- Original Message ----- From: "Richard Quadling" <rquadl...@googlemail.com> To: <prototype-scriptaculous@googlegroups.com> Sent: Monday, September 14, 2009 4:52 PM Subject: [Proto-Scripty] Re: checkboxes 2009/9/14 Russell Keith <russell.ke...@aacreditunion.org>: > I have the following code that works just fine. I can’t figure out how to > tell how many check boxes are checked. I want to limit it to four check > boxes. Any help would be appreciated, or even a point in the right > direction. > > > > $$('input.check').each(function(elem){ > > elem.observe('click', function(){ > > alert(elem.id); > > }); > > }); > > > > I have a similar process. My solution was to put the <input type="checkbox"> into a <div id="cb_div"> I then use ... $('cb_div').observe('click', function(ev){ if (4 == $$('cb_div input[type="checkbox"][checked="checked"]').length) { ev.stop(); return false; } }); sort of thing. Basically use a selector to find the number of checked checkboxes inside the div holding the checkboxes. If this number is equal to or greater than 4, then don't bubble the event / ignore the event. If it is less than 4, then do nothing as the event will bubble and the checkbox will get its click. -- ----- Richard Quadling "Standing on the shoulders of some very clever giants!" EE : http://www.experts-exchange.com/M_248814.html Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 ZOPA : http://uk.zopa.com/member/RQuadling --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---