<script type="text/javascript">
/* グループ化したラジオボタンで選択された値を取得する */
function getRadioLen(){
/* 'a'という名前のラジオボタンの数を取得 */
var lenA=document.form3.a.length;
/* ループして選択された項目を調べ、その値をアラート表示 */
for(var i=0; i<lenA; i++){
if(document.form3.a[i].checked==true){
alert(document.form3.elements['a'][i].value);
}
}
}
</script>
<form name="form3" action="#">
<input type="radio" name="a" value="A" />項目A
<input type="radio" name="a" value="B" checked="checked" />項目B
<input type="radio" name="a" value="C" />項目C
<input type="button" value="選択された値を取得" onclick="getRadioLen()" />
</form>