<input type="radio" name="abc" value="hello" />
<input type="radio" name="abc" value="world" />
<input type ="button" onclick=printOut() />
以下是Javascript代碼:
function printOut(){
var list = document.getElementsByName("abc");
for( i =0 ; i<list.length; i++ ){
if( list[i].checked == true ){
alert(list[i].value);
break;
}
}
}