简单:怎么样让多个复选框全选??? 如果全部是form1的项目,你可以用循环来完成,先取得所有的复选框数组,再一个一个的设置,不过这样不一定方便,虽然编的时候要输入的比较多,但这样不容易出错,而且速度还要快些。当然如果你想以后也用这个方法来作,也是可以的。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <script>function selectall(){ var i; var es = document.form1.elements ; for(i=0;i<es.length;i++){ if (es[i].type=="checkbox") es[i].checked=true; }}</script><form name=form1><input type=checkbox name=a value=a><input type=checkbox name=b value=a><input type=checkbox name=c value=a><input type=button name=b value=selectall onclick=selectall()></form> or:<script>function selectall(){ var i; var es = document.all.tags("input") ; for(i=0;i<es.length;i++){ if (es[i].type=="checkbox") es[i].checked=true; }}</script><form name=form1><input type=checkbox name=a value=a><input type=checkbox name=b value=a><input type=checkbox name=c value=a><input type=button name=b value=selectall onclick=selectall()></form> 当你选种甬道的项时,把所选的结果放到一个数组里面,取值时把数组的内容读出就可以了。<input type="checkbox" name="name" value="a"><input type="checkbox" name="name" value="b"><input type="checkbox" name="name" value="c">......如在jsp页面中:<% String[] check=request.getParameterValues("name"); for(int i=0;i<check.length;i++) { name=check[i]; }%> <input type=checkbox name=a value=a><br><input type=checkbox name=b value=a><br><input type=checkbox name=a value=a><br><input type=checkbox name=b value=a><br><input type=checkbox name=c value=a><br><br><br><input type=checkbox name=d onclick="cc(this)">全选与不全选的切换<script language=Javascript>function cc(tt){ var aa = document.getElementsByTagName("input"); var bb = tt.checked; //得到那个总控的复选框的选中状态 for (var i=0; i<aa.length; i++) { if (aa[i].type == "checkbox") aa[i].checked = bb; }}</script> <script>function selectall(){ var i; var es = document.all.tags("input") ; for(i=0;i<es.length;i++){ if (es[i].type=="checkbox") es[i].checked=true; }}</script><form name=form1><input type=checkbox name=a value=a><input type=checkbox name=b value=a><input type=checkbox name=c value=a><input type=button name=b value=selectall onclick=selectall()></form> 好,如果这么热心的人越来越多,就有希望了,是吧,zsq0759 (john.zhong) ???? 如何给元素注册事件方法 js 调用OCX控件,如何传递BSTR类型参数 getTime方法的使用问题 100分求教,JAVASCRIPT初学者看什么收最好 发现一个关于javascript日期存在的bug,不知道是否是普遍现象~ 在firefox里如何触发<a>中的Click方法? JAVASCRIPT里面什么时候用双引号,什么时候用单引号 关于使用onbeforeunload()来判断关闭IE操作时的问题 javascript和vbscript互相的问题 Javascript数组基本操作问题,谢谢帮忙!在线等待中…… 很急问题:关于分辨率,在线等待! 如何实现关闭页面的功能
function selectall(){
var i;
var es = document.form1.elements ;
for(i=0;i<es.length;i++){
if (es[i].type=="checkbox")
es[i].checked=true;
}
}
</script>
<form name=form1>
<input type=checkbox name=a value=a>
<input type=checkbox name=b value=a>
<input type=checkbox name=c value=a>
<input type=button name=b value=selectall onclick=selectall()>
</form>
function selectall(){
var i;
var es = document.all.tags("input") ;
for(i=0;i<es.length;i++){
if (es[i].type=="checkbox")
es[i].checked=true;
}
}
</script>
<form name=form1>
<input type=checkbox name=a value=a>
<input type=checkbox name=b value=a>
<input type=checkbox name=c value=a>
<input type=button name=b value=selectall onclick=selectall()>
</form>
<input type="checkbox" name="name" value="a">
<input type="checkbox" name="name" value="b">
<input type="checkbox" name="name" value="c">
......
如在jsp页面中:
<%
String[] check=request.getParameterValues("name");
for(int i=0;i<check.length;i++)
{ name=check[i];
}
%>
<input type=checkbox name=b value=a><br>
<input type=checkbox name=a value=a><br>
<input type=checkbox name=b value=a><br>
<input type=checkbox name=c value=a><br><br><br>
<input type=checkbox name=d onclick="cc(this)">全选与不全选的切换<script language=Javascript>
function cc(tt)
{
var aa = document.getElementsByTagName("input");
var bb = tt.checked; //得到那个总控的复选框的选中状态
for (var i=0; i<aa.length; i++)
{
if (aa[i].type == "checkbox")
aa[i].checked = bb;
}
}
</script>
function selectall(){
var i;
var es = document.all.tags("input") ;
for(i=0;i<es.length;i++){
if (es[i].type=="checkbox")
es[i].checked=true;
}
}
</script>
<form name=form1>
<input type=checkbox name=a value=a>
<input type=checkbox name=b value=a>
<input type=checkbox name=c value=a>
<input type=button name=b value=selectall onclick=selectall()>
</form>