js動態級聯二級菜單

來源:互聯網
上載者:User

剛才幫小高做了個動態調取資料的JS菜單效果,弄了一下,記錄下來以備後來用到。

<script>
function showsubmenu(sid)
{
whichEl = eval("submenu" + sid);
imgmenu = eval("imgmenu" + sid);
if (whichEl.style.display == "none")
{
eval("submenu" + sid + ".style.display=/"/";");
imgmenu.background="nimages/admin_2.GIF";
}
else
{
eval("submenu" + sid + ".style.display=/"none/";");
imgmenu.background="nimages/admin_1.GIF";
}
}

function loadingmenu(id){
var loadmenu =eval("menu" + id);
if (loadmenu.innerText=="Loading..."){
document.frames["hiddenframe"].location.replace("LeftTree.asp?menu=menu&id="+id+"");
}
}
</script>

 

 

<%
    set rs=server.CreateObject("adodb.recordset")
    rs.open "select * from xr_anclass order by anclassidorder",conn,1,1
    if rs.recordcount=0 then
    response.write "<br>目前沒有商品分類"
    else
    i=1
    do while not rs.eof
  %>     
 
<table border="0" width="158" cellspacing="0" cellpadding="0">
    <tr id="imgmenu<%=i%>" onClick="showsubmenu(<%=i%>)"  style="cursor:hand" class="menul">
        <td width="20" height="28" align="center"><img name="index_pic_r16_c6" src="images/index_pic_r16_c6.jpg" width="13" height="13" border="0" id="index_pic_r16_c6" alt="" /></td>
        <td width="160"><%=rs("anclass")%></td>
            </tr>
     <tr>
        <td height="1" colspan="2" background="images/left_bg2.gif"></td>
        </tr>      
    <tr>
        <td id="submenu<%=i%>" colspan="2" style="display:none" >
        <table border="0" width="100%" cellspacing="0" cellpadding="0" height="18">
            <tr>
                <td class="table00<%=i%>" height="23">
               
               
                <table border="0" width="100%" cellspacing="0" cellpadding="0" height="23">
                  <%
           set r1=server.CreateObject("adodb.recordset")
           r1.open "select * from xr_nclass where anclassid="&rs("anclassid"),conn,1,1
           if r1.recordcount=0 then
           %>
            <tr>
             <td></td>
            </tr>
           <%
           else
           do while not r1.eof
            %>
                  <tr>
                        <td height="23">&nbsp;
                        ☉ <a href='shoplist.asp?lx=small&anid=<%=rs("anclassid")%>&nid=<%=r1("nclassid")%>'><%=r1("nclass")%></a></td>
                  </tr>
                <%
          r1.movenext
          if r1.eof then exit do
          loop
          end if
          r1.close
          set r1=nothing
         %>
                </table>
              </td>
            </tr>
        </table>
        </td>
    </tr>
</table>

  <%
    rs.movenext
    i=i+1
    if rs.eof then exit do
    loop
    end if
    rs.close
    set rs=nothing
  %>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.