James Starmer
Which Radio Button Is Selected
Rex Chung has a great one line script to find a checked radio button out of a set with the same name attribute using prototype.js.
var typeValue = Form.getInputs('myform','radio','type').find(function(radio) { return radio.checked; }).value;
I’m not very experienced with prototype’s form handling functions and I had no idea that you could do this with Form.getInputs. The funny thing is I’ve run into this issue and hacked up my own solutions to this problem before. I never thought to search for a prototype specific solution though. Great stuff!
