<!DOCTYPE html>
<html>
<head>
<title>性格测试</title>
<meta charset=UTF-8>
<script type="text/javascript">
function test(){
var oRds = document.getElementsByName("music");
var value;
for(var x = 0;x<oRds.length;x++){
if(oRds[x].checked){
value = oRds[x].value;
alert(value);
}
}
}
</script>
</head>

<body>
<div>您喜欢什么类型的音乐?</div>
<input type="radio" value="1" name="music"/>民谣
<input type="radio" value="2" name="music"/>古筝
<input type="radio" value="3" name="music"/>钢琴
<input type="radio" value="4" name="music"/>爵士
<input type="radio" value="5" name="music"/>电音<br>
<button id="resBtn" οnclick="test()">测试结果</button>
</body>
</html>


radio单选按钮2_radio