In the Prototype javascript library, there’s a utility function, $F, which gets value of a form control. It doesn’t work quite so well for Radio Buttons.
The following code does not work:
<input type="radio" name="myRadio" value="one"/>
<input type="radio" name="myRadio" value="two"/>
<input type="radio" name="myRadio" value="three"/>
<input type="button" onclick="alert($F('myRadio'))"/>
I created another function which gets you the value of the radio button:
function $RF(el) {
return Form.getInputs($(el).form, 'radio', $(el).name).find(
function (radioElement) {
return radioElement.checked;
}).value;
}
<input type="radio" name="myRadio" value="one"/>
<input type="radio" name="myRadio" value="two"/>
<input type="radio" name="myRadio" value="three"/>
<input type="button" onclick="alert($RF('myRadio'))"/>