I have a single radio button element (which is passed in via an Observer) and I want to detect if ANY of the radio buttons in it''s group are checked. How can I query all the radio buttons on the page in it''s group with just the element? Thanks. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
// all radio input elements that are of the same name ("radioName") $$(''input[type=radio][name=''+ radioName +'']''); // same as above, but also "checked" $$(''input[type=radio][name=''+ radioName +'']:checked''); // are any checked? !!$$(''input[type=radio][name=''+ radioName +'']:checked'').length; // or $$(''input[type=radio][name=''+ radioName +'']'').any(function(el) { return el.checked; }) - kangax On Jun 16, 6:33 pm, louis w <louiswa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have a single radio button element (which is passed in via an > Observer) and I want to detect if ANY of the radio buttons in it''s > group are checked. > > How can I query all the radio buttons on the page in it''s group with > just the element? > > Thanks.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
YOU ROCK. :) Thanks for the help, such a simple but powerful solution. I subscribed to your blog. On Jun 17, 1:21 am, kangax <kan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> // all radio input elements that are of the same name ("radioName") > $$(''input[type=radio][name=''+ radioName +'']''); > > // same as above, but also "checked" > $$(''input[type=radio][name=''+ radioName +'']:checked''); > > // are any checked? > !!$$(''input[type=radio][name=''+ radioName +'']:checked'').length; > // or > $$(''input[type=radio][name=''+ radioName +'']'').any(function(el) { > return el.checked; > > }) > > - kangax > > On Jun 16, 6:33 pm, louis w <louiswa...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I have a single radio button element (which is passed in via an > > Observer) and I want to detect if ANY of the radio buttons in it''s > > group are checked. > > > How can I query all the radio buttons on the page in it''s group with > > just the element? > > > Thanks.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---