JavaScript實現獲取radio的值
做web時用到的js的功能,備份一下.注意radio也有屬性checked.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>無標題文件</title>
</head>
<body>
<script>
function selectRadio(radioname,url){
var aa = document.getElementsByName(radioname);
for (var i=0; i<aa.length; i++)
{
if(aa[i].checked){
window.location=url+aa[i].value;
}
}
}
</script>
<input name="button" type="button" onclick="return selectRadio('radiobutton','/cn/manager/project/');" value="提交"/>
<br>
<input type="radio" name="radiobutton" value="radiobutton1">
<input type="radio" name="radiobutton" value="radiobutton2">
<input type="radio" name="radiobutton" value="radiobutton3">
</p>
</body>
</html>