不选的功能实现不了 哪里出错了
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- TemplateBeginEditable name="doctitle" -->
<title>无标题文档</title>
<!-- TemplateEndEditable -->
<!-- TemplateBeginEditable name="head" -->
<!-- TemplateEndEditable -->
</head>
<body>
<script type="text/javascript">
function xuan()
{
var a=document.getElementsByName("sport")
for(var i=0;i<=a.length;i++)
a[i].checked="true"
}
function buxuan()
{
var a=document.getElementsByName("sport")
for(var i=0;i<=a.length;i++)
a[i].checked="false"
}
</script>
<p>
请选择你的爱好:
</p>
<input type="checkbox" name="sport" value="爬山">爬山
<input type="checkbox" name="sport" value="游泳">游泳
<p>
<input type="button" value="全选" onclick="xuan()"/>
<input type="button" value="全不选" onclick="buxuan()"/>
</p>
</body>
</html>