复选框做成单选的效果
<!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=utf-8">
<title>单选框做成复选框效果</title>
<Script Language="JScript">
function checkedThis(obj,obj){
var boxArray = document.getElementsByName(obj.name);
//window.alert(obj.name);
for(var i=0;i<=boxArray.length-1;i++){
if(boxArray[i]==obj && obj.checked){
boxArray[i].checked = true;
}else{
boxArray[i].checked = false;
}
}
}
</Script>
</head>
<body>
<p>单选框一</p>
<input type="checkbox" name="test" onclick="checkedThis(this,this);">1
<input type="checkbox" name="test" onclick="checkedThis(this,this);">2
<input type="checkbox" name="test" onclick="checkedThis(this,this);">3
</br>
<p>单选框二</p>
<input type="checkbox" name="test1" onclick="checkedThis(this,this);">4
<input type="checkbox" name="test1" onclick="checkedThis(this,this);">5
<input type="checkbox" name="test1" onclick="checkedThis(this,this);">6
</body>
</html>