Radio Object

Last updated: June 20th, 2004

Radio buttons (<input type="radio">) within your form can be accessed and manipulated using
JavaScript via the corresponding Radio object. There are two ways to access a
radio button, depending on whether it it unique in the form (distinct name), or part
of a group of radio buttons, all sharing the same name.

Distinct Name:

document.myform.radioname //where myform and radioname are
names of your form/element.
document.myform.elements[i] //where i is the position of the radio button within form

Shared Names (part of a group of radio buttons):

document.myform.radioname[i] //where i is the position of the radio
within the group of radio buttons.

<script type="text/javascript">
//a variable that will hold the index number of the selected radio button
for (i=0;i<document.test.myradio.length;i++){
if (document.test.myradio[i].checked==true)
theone=i
}
</script>