求助,哪位高手帮我看下这段代码,三级折叠菜单,标题名从数据库读的。
<!--#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 编辑 ]