日期:2014-05-18  浏览次数:20681 次

一组复选框,复选项目数至少6个,要求某些选择项不能同时选中?
求助大家这个怎么写html语言?能写个例子给我参考下吗?xiexie  



------解决方案--------------------
<html>
<head>
<meta http-equiv= "content-type " content= "text/html;charset=gb2312 " />
<script type= "text/javascript ">
function foo() {
var checkbox01 = document.getElementsByName( "checkbox01 ") ;

// 第一个和第二个复选框不能同时选中,只能选择其中的一个,是哪个可由下标的值来控制
if(checkbox01[0].checked && checkbox01[1].checked) {
checkbox01[0].checked = false ;
}
}
</script>
</head>
<body>

<input type= "checkbox " name= "checkbox01 " onclick= "foo() " /> aaa <br />
<input type= "checkbox " name= "checkbox01 " onclick= "foo() " /> bbb <br />
<input type= "checkbox " name= "checkbox01 " /> ccc <br />
<input type= "checkbox " name= "checkbox01 " /> ddd <br />
<input type= "checkbox " name= "checkbox01 " /> eee <br />
<input type= "checkbox " name= "checkbox01 " /> fff <br />
</body>
</html>