Hi, Pardon me if this question is already asked. I wonder if anyone know where I can find the snippet of code that will allow me to do "check all" and "uncheck all" in a list view of items. I am trying to see if there is any rails api i can use instead of "raw" javascript. Thanks in advance. Regards, Chester -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
pass it the form id and true/false and this should do it: function toggleCheck (form_id, checked) { var form = $(form_id); for (var i = 0; i < form.elements.length; i++) { form.elements[i].checked = checked; } } On 9/14/06, Chester Chee <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Hi, > > Pardon me if this question is already asked. I wonder if anyone know > where I can find the snippet of code that will allow me to do "check > all" and "uncheck all" in a list view of items. I am trying to see if > there is any rails api i can use instead of "raw" javascript. Thanks in > advance. > > Regards, > Chester > > -- > Posted via http://www.ruby-forum.com/. > > > >-- Ed Hickey Developer Litmus Media 816-533-0409 ehickey-A4HEbNdjHgMmlAP/+Wk3EA@public.gmane.org A Member of Think Partnership, Inc www.ThinkPartnership.com Amex ticker symbol: THK --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
This should select and check all the inputs in the element with id ''#container'' to uncheck them, just change the checked to false <%=link_to_function "Select All", update_page {|page| page.select(''#container input'').each {|x|x.checked = true}}%> e.g this will check the following checkboxes <div id="container"> <input type="checkbox" name="loves[ruby]"> i love ruby <input type="checkbox" name="loves[rails]"> i love rails </div> Hope this helps! Cheery-O! Gustav gustav-PUm+PnBUKx7YkQIYctQFYw@public.gmane.org itsdEx.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---