Search code examples
javascriptprototypejs

Getting all radio buttons in a form using Prototype or plain JavaScript?


I have a simple form which includes lots of radio buttons. Some of them are selected, some of the are not. Is there a way to get them all and set them to not checked. I guess setting to not checked can be done like this:

button.checked = false;

Question is, how do I get all the buttons?

Thanks!


Solution

  • $$('input[type="radio"]:checked').each(function(c){
        $(c).checked = false;
    });