<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<title>
javascript获取
单选按钮radio的值 - www.osxue.com</title>
<script language="javascript" >
function abc(){
var sex=document.getelementsbyname("usersex"); //不能getelementbyid,byid又只会读数组第一个值
for(var i = 0; i < sex.length; i++)
{
if(sex[i].
checked){
alert(sex[i].value);
}
}
}
</script>
</head>
<body>
<input id="usersex" name="usersex" type="radio" value="0" checked="checked" />
<span class="style1">男</span>
<input id="usersex" name="usersex" type="radio" value="1" />
<span class="style1">女</span>
<input id="usersex" name="usersex" type="radio" value="2" />
<span class="style1">保密</span>
<input type="button" onclick="abc()" value="取值">
</body>
</html>