October 26th, 2007 Using Prototype Javascript to set the value of a radio group

Not that long ago I wrote Using Prototype Javascript to get the value of a radio group, but I keep getting asked how to set the value of a radio group using prototype JS. Here are a couple ways to do just that.

$$("input[type=radio][name='radioGroupName'][value='yourDefaultValue']").writeAttribute("checked", "checked");
$("someRadioGroupMember").writeAttribute("checked", "checked");

2 Responses to “Using Prototype Javascript to set the value of a radio group”

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Search