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']")[0].writeAttribute("checked", "checked"); $("someRadioGroupMember").writeAttribute("checked", "checked");

Daniel Wintschel Says:
Hmm… The latter was the one I wanted to use, but it didn’t work for me… I used this instead, which worked a-ok.
$(”someRadioGroupMember”).checked = true;
Aaron D. Campbell Says:
What version of Prototype were you using?
Rob Says:
It didn’t work for me either
$$(”input[type=radio][name='groupname'][value='myvalue']“).writeAttribute is not a function
Prototype 1.6.0
Aaron D. Campbell Says:
Rob: Sorry, there was a mistake in that. there should have been a “[0]” following the $$(). Try it with the updated code.