循环一下不就可以了啊,看看csdn的源文件

解决方案 »

  1.   

    CSDN也没有实现这样的功能也只是选择哪一个就是哪一个,没有联系起来的.
      

  2.   

    参看下面代码,选中全部的。将它变通一下就可以用了;
    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;
    }
    }
      

  3.   

    <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>
      

  4.   

    谢谢: zhaoxiaoyang(梅雪香@hisoft)但是另外一种情况:即选择子目录的同时,如何选定其父目录。
      

  5.   

    for(var i=0;i<chks.length;i++)
    {
    if(chks[i].checked=obj.checked)
    {
    obj.flag="main".checked=true;
    break;
    }
    }
    这样写的,结果倒是得到了.
    但还是不理想...
      

  6.   

    <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>