Forum: Rails Spinoffs (closed, excessive spam) Selecting radio group from element

54c4985debe9ede54b95597ada6532fa?d=identicon&s=25 louis w (Guest)
on 2008-06-17 00:35
(Received via mailing list)
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.
F1fcf834ddad415f60d29c87cc10d4d4?d=identicon&s=25 kangax (Guest)
on 2008-06-17 07:22
(Received via mailing list)
// 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
54c4985debe9ede54b95597ada6532fa?d=identicon&s=25 louis w (Guest)
on 2008-06-17 15:51
(Received via mailing list)
YOU ROCK. :)
Thanks for the help, such a simple but powerful solution.

I subscribed to your blog.
This topic is locked and can not be replied to.