请问怎样用js实现多选??(一天内结帐)

我想在单击一按扭后,所有的checkbox都被选中,请问应该怎么
实现啊,给出源代码最好,谢谢各位!
---------------------------------------------------------------

1<input type="checkbox"/>
1<input type="checkbox"/>
1<input type="checkbox"/>
1<input type="checkbox"/>
1<input type="checkbox"/>
1<input type="checkbox"/>
1<input type="checkbox"/>
1<input type="checkbox"/>
1<input onclick="mm()" type="button" value="Check All"/>
 1<script language="javascript">   
 2function mm()   
 3{   
 4var a = document.getElementsByTagName("input");   
 5if(a[0].checked==true){   
 6for (var i=0; i<a.length; i++)   
 7if (a[i].type == "checkbox") a[i].checked = false;   
 8}   
 9else   
10{   
11for (var i=0; i<a.length; i++)   
12if (a[i].type == "checkbox") a[i].checked = true;   
13}   
14}   
15</script>
Published At
Categories with Web编程
comments powered by Disqus