标题:求助,哪位高手帮我看下这段代码,三级折叠菜单,标题名从数据库读的。
取消只看楼主
luckystar_t
Rank: 1
等 级:新手上路
帖 子:20
专家分:5
注 册:2011-6-18
结帖率:66.67%
已结贴  问题点数:20 回复次数:6 
求助,哪位高手帮我看下这段代码,三级折叠菜单,标题名从数据库读的。
<!--#include file="conn.asp" -->
<html>
<head>
<title></title>
<style>
*,body,ul,li,h1,h2{ margin:0; padding:0; list-style:none;}
body{font:12px "宋体"; padding-top:20px;}
#menu { width:200px; margin:auto;}
    #menu h1 { cursor:pointer; color:#FFF; font-size:12px; padding:5px 0 3px 10px; border:#C60 1px solid; margin-top:1px;  background-color:#F93;}
    #menu h2 { cursor:pointer; color:#777; font-size:12px; padding:5px 0 3px 10px; border:#E7E7E7 1px solid; border-top-color:#FFF; background-color:#F4F4F4;}
    #menu ul { padding-left:15px; height:100px;border:#E7E7E7 1px solid; border-top:none;overflow:auto;}
    #menu ul li {padding:5px 0 3px 10px;}
    .no { display:none;}
</style>
<script language="JavaScript">
<!--//
function ShowMenu(obj,noid){
    var block =    document.getElementById(noid);
    var n = noid.substr(noid.length-1);
    if(noid.length==4){
        var ul = document.getElementById(noid.substring(0,3)).getElementsByTagName("ul");
        var h2 = document.getElementById(noid.substring(0,3)).getElementsByTagName("h2");
        for(var i=0; i<h2.length;i++){
            h2[i].innerHTML = h2[i].innerHTML.replace("+","-");
            h2[i].style.color = "";
        }
        obj.style.color = "#FF0000";
        for(var i=0; i<ul.length; i++){if(i!=n){ul[i].className = "no";}}
    }else{
        var span = document.getElementById("menu").getElementsByTagName("span");
        var h1 = document.getElementById("menu").getElementsByTagName("h1");
        for(var i=0; i<h1.length;i++){
            h1[i].innerHTML = h1[i].innerHTML.replace("+","-");
            h1[i].style.color = "";
        }
        obj.style.color = "#0000FF";
        for(var i=0; i<span.length; i++){if(i!=n){span[i].className = "no";}}
    }
    if(block.className == "no"){
        block.className = "";
        obj.innerHTML = obj.innerHTML.replace("-","+");
    }else{
        block.className = "no";
        obj.style.color = "";
    }
}
//-->
</script>
</head>
<body>
<div id="menu">
<%
set rs_Pro1=server.createobject("adodb.recordset")
sqltext4=" select* from Hope_ProductClassid where parentid=0 and  parentid1=1 order by id desc"
rs_Pro1.open sqltext4,conn,1,1                     
%>            
  <%                                   '一级菜单
  dim m
  m=0
  do while not rs_Pro1.eof
  %>


    <h1 onClick="javascript:ShowMenu(this,'<%=m%>')">- <%=rs_Pro1("classname")%></h1>
    <span id="<%=m%>" class="no">
   

<%
            '2级菜单循环
set rs_Pro2=server.createobject("adodb.recordset")
sqltext4="select * from Hope_ProductClassid where parentid="& rs_Pro1("id") &" order by id desc"
rs_Pro2.open sqltext4,conn,1,1                 
%>   
               <%
               dim x
               x=0
               do while not rs_Pro2.eof
               %>
        <h2 onClick="javascript:ShowMenu(this,'<%=x%>')">- <%=rs_Pro2("classname")%></h2>

                     
        <ul id="<%=x%>" class="no">
                               <%
                                         '3级菜单循环
                              set rs_Pro3=server.createobject("adodb.recordset")
                              sqltext4="select * from Hope_ProductClassid where parentid1="& rs_Pro2("id") &" order by id desc"
                              rs_Pro3.open sqltext4,conn,1,1   
                           do while not rs_Pro3.eof            
                              %>                              
            <li><%=rs_Pro3("classname")%></li>
                              <%
                           rs_Pro3.movenext
                             loop
                           rs_Pro3.close
                          %>
        </ul>
            <%
              x=x+1
              rs_Pro2.movenext
              loop
              rs_Pro2.close
              %>
    </span>
<%
    m=m+1
    rs_Pro1.movenext
    loop
    rs_Pro1.close
%>
</div>
</body>
</html>
sql语句不用看了,是没错滴 我qq1102211065,问题出现在,点击一级标题能弹出二级菜单,点击其他一级菜单刚才菜单能收回去,这点已经达到,但是当点击二级菜单的时候,不能弹出三级菜单,而且被点击的菜单会收回去,求解,困恼了一天了都没看出来问题

[ 本帖最后由 luckystar_t 于 2011-7-8 10:08 编辑 ]
搜索更多相关主题的帖子: 数据库 
2011-07-08 10:00
luckystar_t
Rank: 1
等 级:新手上路
帖 子:20
专家分:5
注 册:2011-6-18
得分:0 

<html>
<head>
<title></title>
<style>
*,body,ul,li,h1,h2{ margin:0; padding:0; list-style:none;}
body{font:12px "宋体"; padding-top:20px;}
#menu { width:200px; margin:auto;}
    #menu h1 { cursor:pointer; color:#FFF; font-size:12px; padding:5px 0 3px 10px; border:#C60 1px solid; margin-top:1px;  background-color:#F93;}
    #menu h2 { cursor:pointer; color:#777; font-size:12px; padding:5px 0 3px 10px; border:#E7E7E7 1px solid; border-top-color:#FFF; background-color:#F4F4F4;}
    #menu ul { padding-left:15px; height:100px;border:#E7E7E7 1px solid; border-top:none;overflow:auto;}
    #menu ul li {padding:5px 0 3px 10px;}
    .no { display:none;}
</style>
<script language="JavaScript">
<!--//
function ShowMenu(obj,noid){
    var block =    document.getElementById(noid);
    var n = noid.substr(noid.length-1);
    if(noid.length==4){
        var ul = document.getElementById(noid.substring(0,3)).getElementsByTagName("ul");
        var h2 = document.getElementById(noid.substring(0,3)).getElementsByTagName("h2");
        for(var i=0; i<h2.length;i++){
            h2[i].innerHTML = h2[i].innerHTML.replace("+","-");
            h2[i].style.color = "";
        }
        obj.style.color = "#FF0000";
        for(var i=0; i<ul.length; i++){if(i!=n){ul[i].className = "no";}}
    }else{
        var span = document.getElementById("menu").getElementsByTagName("span");
        var h1 = document.getElementById("menu").getElementsByTagName("h1");
        for(var i=0; i<h1.length;i++){
            h1[i].innerHTML = h1[i].innerHTML.replace("+","-");
            h1[i].style.color = "";
        }
        obj.style.color = "#0000FF";
        for(var i=0; i<span.length; i++){if(i!=n){span[i].className = "no";}}
    }
    if(block.className == "no"){
        block.className = "";
        obj.innerHTML = obj.innerHTML.replace("-","+");
    }else{
        block.className = "no";
        obj.style.color = "";
    }
}
//-->
</script>
</head>
<body>
<div id="menu">



    <h1 onClick="javascript:ShowMenu(this,'0')">- 台球配件</h1>
    <span id="0" class="no">
   


        <h2 onClick="javascript:ShowMenu(this,'0')">- 台球饰品</h2>

                     
        <ul id="0" class="no">
                              
        </ul>
              
    </span>



    <h1 onClick="javascript:ShowMenu(this,'1')">- 台球桌</h1>
    <span id="1" class="no">
   


        <h2 onClick="javascript:ShowMenu(this,'0')">- 奥得威(OLD WORLD)</h2>

                     
        <ul id="0" class="no">
                              
        </ul>
              
        <h2 onClick="javascript:ShowMenu(this,'1')">- 亚力士(AILEEX)</h2>

                     
        <ul id="1" class="no">
                              
        </ul>
              
    </span>



    <h1 onClick="javascript:ShowMenu(this,'2')">- 球杆盒筒</h1>
    <span id="2" class="no">
   


        <h2 onClick="javascript:ShowMenu(this,'0')">- 斯诺克杆盒</h2>

                     
        <ul id="0" class="no">
                              
        </ul>
              
        <h2 onClick="javascript:ShowMenu(this,'1')">- 九球杆筒</h2>

                     
        <ul id="1" class="no">
                              
        </ul>
              
    </span>



    <h1 onClick="javascript:ShowMenu(this,'3')">- 美式球杆</h1>
    <span id="3" class="no">
   


        <h2 onClick="javascript:ShowMenu(this,'0')">- 毒药(POISON)</h2>

                     
        <ul id="0" class="no">
                              
        </ul>
              
        <h2 onClick="javascript:ShowMenu(this,'1')">- 力国(Licos)</h2>

                     
        <ul id="1" class="no">
                              
        </ul>
              
    </span>



    <h1 onClick="javascript:ShowMenu(this,'4')">- 英式球杆</h1>
    <span id="4" class="no">
   


        <h2 onClick="javascript:ShowMenu(this,'0')">- JOHN PARRIS</h2>

                     
        <ul id="0" class="no">
                              
        </ul>
              
        <h2 onClick="javascript:ShowMenu(this,'1')">- MASTER</h2>

                     
        <ul id="1" class="no">
                              
        </ul>
              
        <h2 onClick="javascript:ShowMenu(this,'2')">- BS(白沙)</h2>

                     
        <ul id="2" class="no">
                                                         
            <li>二星</li>
                                                         
            <li>一星</li>
                              
        </ul>
              
    </span>

</div>


</body>
</html>
这是查看源文件的内容
2011-07-08 14:06
luckystar_t
Rank: 1
等 级:新手上路
帖 子:20
专家分:5
注 册:2011-6-18
得分:0 
不是啦,最好个菜单有的,关键是现在点二级菜单它还要缩回去
    <h1 onClick="javascript:ShowMenu(this,'4')">- 英式球杆</h1>
    <span id="4" class="no">
   


        <h2 onClick="javascript:ShowMenu(this,'0')">- JOHN PARRIS</h2>

                     
        <ul id="0" class="no">
                              
        </ul>
              
        <h2 onClick="javascript:ShowMenu(this,'1')">- MASTER</h2>

                     
        <ul id="1" class="no">
                              
        </ul>
              
        <h2 onClick="javascript:ShowMenu(this,'2')">- BS(白沙)</h2>

                     
        <ul id="2" class="no">
                                                         
            <li>二星</li>
                                                         
            <li>一星</li>
                              
        </ul>
              
    </span>
2011-07-08 14:53
luckystar_t
Rank: 1
等 级:新手上路
帖 子:20
专家分:5
注 册:2011-6-18
得分:0 
<div id="menu">
<%
set rs_Pro1=server.createobject("adodb.recordset")
sqltext4=" select* from Hope_ProductClassid where parentid=0 and  parentid1=1 order by id desc"
rs_Pro1.open sqltext4,conn,1,1                     
%>            
  <%                                   '一级菜单
  dim m
  m="aa"
  do while not rs_Pro1.eof
  %>


    <h1 onClick="javascript:ShowMenu(this,'<%=m%>')">- <%=rs_Pro1("classname")%></h1>
    <span id="<%=m%>" class="no">
   

<%
            '2级菜单循环
set rs_Pro2=server.createobject("adodb.recordset")
sqltext4="select * from Hope_ProductClassid where parentid="& rs_Pro1("id") &" order by id desc"
rs_Pro2.open sqltext4,conn,1,1                 
%>   
               <%
               dim x
               x="bb"
               do while not rs_Pro2.eof
               %>
        <h2 onClick="javascript:ShowMenu(this,'<%=x%>')">- <%=rs_Pro2("classname")%></h2>

                     
        <ul id="<%=x%>" class="no">
                              <%
                           '3级菜单循环
                              set rs_Pro3=server.createobject("adodb.recordset")
                              sqltext4="select * from Hope_ProductClassid where parentid1="& rs_Pro2("id") &" order by id desc"
                              rs_Pro3.open sqltext4,conn,1,1
                              do while not rs_Pro3.eof                     
                              %>                           
            <li><%=rs_Pro3("classname")%></li>
                              <%
                           rs_Pro3.movenext
                           loop
                           rs_Pro3.close
                          %>
        </ul>
              <%  
              x=x+1
              rs_Pro2.movenext
              loop
              rs_Pro2.close
              %>
    </span>
<%
    m=m+1
    rs_Pro1.movenext
    loop
    rs_Pro1.close
%>
</div>
大哥还是不行额,我这里用了你说的方法,用 “字符串”+1的格式来弄应该就不重复啦,还是不行
2011-07-08 17:55
luckystar_t
Rank: 1
等 级:新手上路
帖 子:20
专家分:5
注 册:2011-6-18
得分:0 
桌面.rar (34.4 KB)
大哥我直接把我的源文件奉上咯- -帮我看看
2011-07-09 10:56
luckystar_t
Rank: 1
等 级:新手上路
帖 子:20
专家分:5
注 册:2011-6-18
得分:0 
知道了- -但是大哥还是不行也,照你的方法改了后,菜单都弹不出了
111.rar (10.96 KB)

这次我把数据库里面的表一下拷上咯- -
2011-07-09 14:07
luckystar_t
Rank: 1
等 级:新手上路
帖 子:20
专家分:5
注 册:2011-6-18
得分:0 
看来我还菜得慌,谢谢你大哥,我还得努力学习才行,学习asp1个多月了,勉强会改点点
2011-07-09 15:50



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-344996-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.158494 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved