其实树很简单,拿一个多级的js树为模型,然后分拆出他的建树函数,最后用你自己的数据生成方式在jsp中out.print出那写分拆了的js树的函数而已

解决方案 »

  1.   

    你照着自己修改把
    ~~~~~~~~~~
    <script language="JavaScript">
    NS4 = (document.layers) ? 1 : 0;
    IE4 = (document.all) ? 1 : 0;
    ver4 = (NS4 || IE4) ? 1 : 0;if (ver4) {
        with (document) {
            write("<STYLE TYPE='text/css'>");
            if (NS4) {
                write(".parent {position:absolute; visibility:visible}");
                write(".child {position:absolute; visibility:visible}");
                write(".regular {position:absolute; visibility:visible}")
            }
            else {
                write(".child {display:none}")
            }
            write("</STYLE>");
        }
    }function getIndex(el) {
        ind = null;
        for (i=0; i<document.layers.length; i++) {
            whichEl = document.layers[i];
            if (whichEl.id == el) {
                ind = i;
                break;
            }
        }
        return ind;
    }function arrange() {
        nextY = document.layers[firstInd].pageY +document.layers[firstInd].document.height;
        for (i=firstInd+1; i<document.layers.length; i++) {
            whichEl = document.layers[i];
            if (whichEl.visibility != "hide") {
                whichEl.pageY = nextY;
                nextY += whichEl.document.height;
            }
        }
    }function initIt(){
        if (!ver4) return;
        if (NS4) {
            for (i=0; i<document.layers.length; i++) {
                whichEl = document.layers[i];
                if (whichEl.id.indexOf("Child") != -1) whichEl.visibility = "hide";
           }
            arrange();
        }
        else {
            divColl = document.all.tags("DIV");
            for (i=0; i<divColl.length; i++) {
                whichEl = divColl(i);
                if (whichEl.className == "child") whichEl.style.display = "none";
            }
        }
    }function expandIt(el) {
        if (!ver4) return;
        if (IE4) {
            whichEl = eval(el + "Child");
            if (whichEl.style.display == "none") {
                whichEl.style.display = "block";
            }
            else {
                whichEl.style.display = "none";
            }
        }
        else {
            whichEl = eval("document." + el + "Child");
            if (whichEl.visibility == "hide") {
                whichEl.visibility = "show";
            }
            else {
                whichEl.visibility = "hide";
            }
            arrange();
        }
    }
    onload = initIt;
    </script>
            </font></p>
    &nbsp;你好:<%=session.getAttribute("username")%>
          <div id="KB1Parent" class="parent"><span class="style4"><a href="#" onClick="expandIt('KB1'); return false" ><img src="img/admin-people.gif" width="32" height="32" border=0><span class="style6">用户管理模块</span></a>
          </span>
            <div class="parent style4" id="KB1Parent"></div>
            <div class="child style3" id="KB1Child"> <a href="disuser.jsp" target="mainFrame"><img src="img/iconGroup.gif" alt="" width="18" height="18"  border=0>用户列表</a><br>
       <a href="d_sql2.jsp" target="mainFrame" ><img src="img/iconGroup.gif" alt="" width="18" height="18"  border=0>查 询</a><br>
       <a href="addmanager.jsp" target="mainFrame"><img src="img/iconGroup.gif" alt="" width="18" height="18"  border=0>添加用户</a><br>
      &nbsp;    <a href="modifymanager.jsp" target="mainFrame"><img src="img/iconGroup.gif" alt="" width="18" height="18"  border=0>修改用户</a><br>
    <a href="del1.jsp" target="mainFrame" >&nbsp;&nbsp;<img src="img/iconGroup.gif" alt="" width="18" height="18"  border=0>删除用户</a></span></div>
    </div>
    <div class="parent style4" id="KB2Parent">
    <a href="#" onClick="expandIt('KB2'); return false" ><img src="img/admin-people.gif" width="32" height="32" border=0><span class="style6">角色与权限模块</span></a></div>   <div class="child style3" id="KB2Child"> <a href="role_list.jsp" target="mainFrame" ><img src="img/iconGroup.gif" alt="" width="18" height="18"  border=0>列表</a><br>
     <a href="role_manager.jsp" target="mainFrame" ><img src="img/iconGroup.gif" alt="" width="18" height="18"  border=0>新建</a></div>
          <div class="parent style4" id="KB3Parent"><a href="#" onClick="expandIt('KB3'); return false" ><img src="img/admin-people.gif" width="32" height="32"  border=0><span class="style6">项目规划模块</span></a></div>
          <div class="child style3" id="KB3Child"><a href="HRaddManager.jsp" target="mainFrame">  <img src="img/iconGroup.gif" alt="" width="18" height="18"  border=0>人力资源计划</a><br>
     <a href="NULL.jsp" target="mainFrame" ><img src="img/iconGroup.gif" alt="" width="18" height="18"  border=0>任务进度计划</a></div>
      
       
            <script language="JavaScript">
    if (NS4) {
            firstEl = "KB1Parent";
            firstInd = getIndex(firstEl);
            arrange();
    }
            </script>