注册 登录
编程论坛 JavaScript论坛

ul列表,点击出现下拉菜单

szchenli 发布于 2010-06-29 17:55, 1355 次点击
ul列表,点击出现下拉菜单
我要实现的是 鼠标点击li标签,出现它的下级菜单
请问怎么实现?
<%
set rs=Server.CreateObject("ADODB.Recordset")
sql="select * from [BigClass] order by BigClassId asc"
rs.open sql,conn,1,1
%>
<ul class="about" >
    <%
    if not rs.eof then
        i=1
        do while not rs.eof
    %>
        <li id="imgmenu<%=i%>" onClick="showsubmenu(<%=i%>)" style="cursor:hand;"><%=rs("BigClassName")%>
            <ul id="submenu<%=i%>" style="DISPLAY: none">
                <%
                sql="select * from [SmallClass] where BigClassName='"&rs("BigclassName")&"' ORDER BY SmallClassID ASC"
                set rss=server.CreateObject("adodb.recordset")
                rss.open sql,conn,1,1
                if rss.recordcount<>0 then
                do while not rss.eof
                %>
                <li><a href="product_list.asp?SmallClassName=<%=rs("SmallClassName")%>" class="aboutlist"><%=rss("SmallClassName")%></a></li>
                <%
                rss.movenext
                loop
                end if
                rss.close
                set rss = nothing
                %>
            </ul>
        </li>
    <%
              rs.movenext
        loop
    end if
    rs.close
    set rs=nothing
    %>
</ul>
7 回复
#2
poyexyp2010-06-29 18:04
DOM获取该li,然后onclick事件,相应的submenu的style.display="",如果是要点击toggle的话display=display=="none"?"":""
#3
szchenli2010-06-29 18:07
能写详细点么?就是怎么用DOM获取,他是个循环,谢谢

[ 本帖最后由 szchenli 于 2010-6-29 18:08 编辑 ]
#4
poyexyp2010-06-29 18:15
onClick="showsubmenu(<%=i%>)不是已经写了脚本了么,在源文件或者js文件里找到showsubmenu函数就可以了

类似这个的
function showsubmenu(num){
theId='submenu'+num;
var theUl=document.getElementById(theId);
theUl.style.display=theUl.style.display=="none"?"":"none";
}


[ 本帖最后由 poyexyp 于 2010-6-29 19:45 编辑 ]
#5
szchenli2010-06-29 18:33
脚本是我自己写的,我想这样做,但我不晓得showsubmenu()这个函数怎么写?
你现在写的,用不了
#6
poyexyp2010-06-29 19:52
哦,下班的时候敲得匆忙了,有点错误,已修正
#7
szchenli2010-06-29 20:22
http://sansi.145.
还是有点问题,页面上有两个,现在只有一个能弹出来
#8
szchenli2010-06-29 20:52
不用了,现在可以了,是我的代码写错了少了 i=i+1。谢谢啊,分给你了,辛苦
1