Js对复选框的选择问题 循环一下不就可以了啊,看看csdn的源文件 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 CSDN也没有实现这样的功能也只是选择哪一个就是哪一个,没有联系起来的. 参看下面代码,选中全部的。将它变通一下就可以用了;function CheckAll(form){for (var i=0;i<form.elements.length;i++){var e = form.elements[i];if (e.name != 'chkAll')e.checked = form.chkAll.checked;}} <script language="JavaScript"><!--function chkClk(obj){ var chks=document.getElementsByName(obj.name); //alert(chks.length); if(obj.flag=="main"){ for(var i=1;i<chks.length;i++) chks[i].checked=obj.checked; }}//--></script><input type="checkbox" onclick="chkClk(this)" name="type1" flag="main">typetext<li><input type="checkbox" onclick="chkClk(this)" name="type1">typetext</li><li><input type="checkbox" onclick="chkClk(this)" name="type1">typetext</li><li><input type="checkbox" onclick="chkClk(this)" name="type1">typetext</li><li><input type="checkbox" onclick="chkClk(this)" name="type1">typetext</li><li><input type="checkbox" onclick="chkClk(this)" name="type1">typetext</li><li><input type="checkbox" onclick="chkClk(this)" name="type1">typetext</li><br><br><input type="checkbox" onclick="chkClk(this)" name="type2" flag="main">typetext<li><input type="checkbox" onclick="chkClk(this)" name="type2">typetext</li><li><input type="checkbox" onclick="chkClk(this)" name="type2">typetext</li><li><input type="checkbox" onclick="chkClk(this)" name="type2">typetext</li><li><input type="checkbox" onclick="chkClk(this)" name="type2">typetext</li><li><input type="checkbox" onclick="chkClk(this)" name="type2">typetext</li><li><input type="checkbox" onclick="chkClk(this)" name="type2">typetext</li> 谢谢: zhaoxiaoyang(梅雪香@hisoft)但是另外一种情况:即选择子目录的同时,如何选定其父目录。 for(var i=0;i<chks.length;i++){if(chks[i].checked=obj.checked){obj.flag="main".checked=true;break;}}这样写的,结果倒是得到了.但还是不理想... <script language="JavaScript"><!--function chkClk(obj){ var chks=document.getElementsByName(obj.name); //alert(chks.length); if(obj.flag=="main"){ for(var i=1;i<chks.length;i++) chks[i].checked=obj.checked; } else{ for(var i=1;i<chks.length;i++) if(chks[i].checked==false){ chks[0].checked=false; break; } else{ if(i==chks.length-1) chks[0].checked=true; } }}//--></script><input type="checkbox" onclick="chkClk(this)" name="type1" flag="main">typetext<li><input type="checkbox" onclick="chkClk(this)" name="type1">typetext</li><li><input type="checkbox" onclick="chkClk(this)" name="type1">typetext</li><li><input type="checkbox" onclick="chkClk(this)" name="type1">typetext</li><li><input type="checkbox" onclick="chkClk(this)" name="type1">typetext</li><li><input type="checkbox" onclick="chkClk(this)" name="type1">typetext</li><li><input type="checkbox" onclick="chkClk(this)" name="type1">typetext</li><br><br><input type="checkbox" onclick="chkClk(this)" name="type2" flag="main">typetext<li><input type="checkbox" onclick="chkClk(this)" name="type2">typetext</li><li><input type="checkbox" onclick="chkClk(this)" name="type2">typetext</li><li><input type="checkbox" onclick="chkClk(this)" name="type2">typetext</li><li><input type="checkbox" onclick="chkClk(this)" name="type2">typetext</li><li><input type="checkbox" onclick="chkClk(this)" name="type2">typetext</li><li><input type="checkbox" onclick="chkClk(this)" name="type2">typetext</li> 用图片按钮提交其他表单 请教如何定制alert的弹出样式? 真是难以理解,怎么js会写出这样的代码 table1.all('123') 这句话是什么意思? 小问题请教:进度条隐藏的问题 不用window.open()函数可以做一个无边框的窗口吗? javascript网页特效 jscript函数中的return true和return false有何差别?谢谢 如何获得键盘值? 关于readonly与spry验证文本域的问题 判断控件在表格中单元格的位置 很蠢的javascript 问题。。请大家帮忙
function CheckAll(form){
for (var i=0;i<form.elements.length;i++){
var e = form.elements[i];
if (e.name != 'chkAll')
e.checked = form.chkAll.checked;
}
}
<!--
function chkClk(obj){
var chks=document.getElementsByName(obj.name);
//alert(chks.length);
if(obj.flag=="main"){
for(var i=1;i<chks.length;i++)
chks[i].checked=obj.checked;
}
}
//-->
</script><input type="checkbox" onclick="chkClk(this)" name="type1" flag="main">typetext
<li><input type="checkbox" onclick="chkClk(this)" name="type1">typetext</li>
<li><input type="checkbox" onclick="chkClk(this)" name="type1">typetext</li>
<li><input type="checkbox" onclick="chkClk(this)" name="type1">typetext</li>
<li><input type="checkbox" onclick="chkClk(this)" name="type1">typetext</li>
<li><input type="checkbox" onclick="chkClk(this)" name="type1">typetext</li>
<li><input type="checkbox" onclick="chkClk(this)" name="type1">typetext</li>
<br><br>
<input type="checkbox" onclick="chkClk(this)" name="type2" flag="main">typetext
<li><input type="checkbox" onclick="chkClk(this)" name="type2">typetext</li>
<li><input type="checkbox" onclick="chkClk(this)" name="type2">typetext</li>
<li><input type="checkbox" onclick="chkClk(this)" name="type2">typetext</li>
<li><input type="checkbox" onclick="chkClk(this)" name="type2">typetext</li>
<li><input type="checkbox" onclick="chkClk(this)" name="type2">typetext</li>
<li><input type="checkbox" onclick="chkClk(this)" name="type2">typetext</li>
{
if(chks[i].checked=obj.checked)
{
obj.flag="main".checked=true;
break;
}
}
这样写的,结果倒是得到了.
但还是不理想...
<!--
function chkClk(obj){
var chks=document.getElementsByName(obj.name);
//alert(chks.length);
if(obj.flag=="main"){
for(var i=1;i<chks.length;i++)
chks[i].checked=obj.checked;
}
else{
for(var i=1;i<chks.length;i++)
if(chks[i].checked==false){
chks[0].checked=false;
break;
}
else{
if(i==chks.length-1) chks[0].checked=true;
}
}
}
//-->
</script><input type="checkbox" onclick="chkClk(this)" name="type1" flag="main">typetext
<li><input type="checkbox" onclick="chkClk(this)" name="type1">typetext</li>
<li><input type="checkbox" onclick="chkClk(this)" name="type1">typetext</li>
<li><input type="checkbox" onclick="chkClk(this)" name="type1">typetext</li>
<li><input type="checkbox" onclick="chkClk(this)" name="type1">typetext</li>
<li><input type="checkbox" onclick="chkClk(this)" name="type1">typetext</li>
<li><input type="checkbox" onclick="chkClk(this)" name="type1">typetext</li>
<br><br>
<input type="checkbox" onclick="chkClk(this)" name="type2" flag="main">typetext
<li><input type="checkbox" onclick="chkClk(this)" name="type2">typetext</li>
<li><input type="checkbox" onclick="chkClk(this)" name="type2">typetext</li>
<li><input type="checkbox" onclick="chkClk(this)" name="type2">typetext</li>
<li><input type="checkbox" onclick="chkClk(this)" name="type2">typetext</li>
<li><input type="checkbox" onclick="chkClk(this)" name="type2">typetext</li>
<li><input type="checkbox" onclick="chkClk(this)" name="type2">typetext</li>