SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Aug 2004
    Location
    vi
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation Dynamic menu build help

    I need to get my name value "MenuSubCat" to act as athird level menu.
    This is a dynamic menu and it only does

    MenuMenuLabel
    >MenuCat

    I need
    MenuMenuLabel
    >MenuCat
    >MenuSubCat
    Help

    [CODE]
    <table id="DhtmlMenuDiv">
    <%

    do while not rs.EOF

    ':: read db record
    on error resume next
    MenuContentType = rs("MenuContentType")
    MenuParentId = rs("MenuParentId")
    MenuMenuLabel = rs("MenuMenuLabel")
    MenuDefaultURL = rs("MenuDefaultURL")
    MenuCatID = rs("MenuCatID")
    MenuSubCatId = rs("MenuSubCatId")
    MenuSubCat = rs("MenuSubCat")
    MenuCat = rs("MenuCat")
    on error goto 0

    %>
    <% if LastMenuContentType <> MenuContentType then %>
    <%
    if LastMenuContentType<>"" then
    response.write "</ul></li>"
    else
    response.write "<ul id='DhtmlMenu'>"
    end if
    %>
    <li >
    <A id='<% =ctr+1 %>actuator' class='DhtmlMenuLink' href='<% =MenuDefaultURL %>'><% if isNull(MenuMenuLabel) OR MenuMenuLabel="" then%><% =MenuContentType %><% else %><% =MenuMenuLabel %><% end if %></A>
    <ul id='<% =ctr+1 %>menu' class="DhtmlMenuItem">
    <%

    show = TRUE
    ctr = ctr + 1
    end if

    %>

    <% if LastMenuCat <> MenuCat OR Show then %>

    <li><A href='content.asp?CatId=<% =MenuCatId %>'><% =MenuCat%></A></li>

    <%

    show = FALSE
    end if

    recs = recs+1
    LastMenuCat = MenuCat
    LastMenuContentType = MenuContentType
    if recs=num_recs then response.write "</ul></li></ul>"

    %>

    <%

    rs.MoveNext
    rec_count = rec_count + 1
    loop
    rs.Close

    %>

    </table>

  2. #2
    SitePoint Enthusiast
    Join Date
    Jan 2004
    Location
    Hull
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry I dont completely understand your code but do understand what your trying to achieve, how I normally do this is below:

    Code:
    <&#37;
    Dim rsMenu
    Dim rsMenu_numRows
    
    Set rsMenu = Server.CreateObject("ADODB.Recordset")
    rsMenu.ActiveConnection = DSNlessCon
    rsMenu.Source = "SELECT MainCategoryID, MainCategory FROM MainCategories ORDER BY MainCategory ASC"
    rsMenu.CursorType = 0
    rsMenu.CursorLocation = 2
    rsMenu.LockType = 1
    rsMenu.Open()
    
    rsMenu_numRows = 0
    %>
    <ul id="sideNav">
    <% 
    While Not rsMenu.eof 
    	Dim rsSubMenu
    	Dim rsSubMenu_numRows
    
    	Set rsSubMenu = Server.CreateObject("ADODB.Recordset")
    	rsSubMenu.ActiveConnection = DSNlessCon
    	rsSubMenu.Source = "SELECT subCategoryID, subCategory, MainCategoryID FROM subcategories WHERE MainCategoryID="& rsMenu("MainCategoryID") &" ORDER BY subCategory ASC"
    	rsSubMenu.CursorType = 0
    	rsSubMenu.CursorLocation = 3
    	rsSubMenu.LockType = 1
    	rsSubMenu.Open()
    
    	rsSubMenu_numRows = 0
    %>
    <li><a href="#"><%=rsMenu("MainCategory")%></a>
    	<% if rsSubMenu.recordCount <> 0 then %>
    	<ul>
    	<% While Not rsSubMenu.eof %>
    	<li><a href="products.asp?MainCategoryID=<%=rsMenu("MainCategoryID")%>&subCategoryID=<%=rsSubMenu("subCategoryID")%>"><%=rsSubMenu("SubCategory")%></a></li>
    	<% 
      	rsSubMenu.MoveNext()
    	Wend
    	%>
    	</ul>
    	<% 
    	rsSubMenu.Close()
    	Set rsSubMenu = Nothing
    	
    	end if %>
    
    </li>	
    
    </li>
    <% 
      rsMenu.MoveNext()
    Wend
    %>
    </ul>
    <%
    rsMenu.Close()
    Set rsMenu = Nothing
    %>
    Hope that helps
    Last edited by dlw; Dec 29, 2006 at 04:21.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •