Results 1 to 1 of 1

Thread: DB driven tree menu

  1. #1
    Join Date
    Mar 2007
    Posts
    15

    DB driven tree menu

    Hi,

    I am trying to create a menu which is database driven, using classic ASP and an Access DB

    What i want is a nav menu of 'categories' then when the category is click, the sub menu appears below the category name, and then when you click the category again, it closes the sub menu.

    any help much appreciated! desperate need of help cos its driving me crazy.

    ---ok this is what i have got so far

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
    <!--#include file="inc_connection.asp"-->
    <%
    Response.Write "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'>" & vbCRLF
    Response.Write "<HTML>" & vbCRLF

    Response.Write "<HEAD>" & vbCRLF
    Response.write ("<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>")
    Response.Write "<TITLE>"
    Response.Write "</TITLE>" & vbCRLF
    Response.Write("<meta name='description' content=''>")
    Response.Write("<meta name='keywords' content=''>")
    Response.Write "<LINK REL='stylesheet' TYPE='text/css' HREF='style.css'>"
    Response.Write "</HEAD>" & vbCRLF

    %>
    <script type="text/javascript">
    function showHide(el){
    obj = document.getElementById(el).style;
    (obj.display == 'none')? obj.display = 'block' : obj.display = 'none';
    }
    </script>
    <%


    Response.Write "</head>"

    Response.Write "<body>"

    Dim strSQL
    DIm rsTemp
    Dim connTemp


    strSQL = "SELECT * FROM tbl_SWCategories "
    'strSQL = strSQL & "LEFT JOIN tbl_SWSubCategories "
    'strSQL = strSQL & "ON tbl_SWCategories.CategoryID = tbl_SWSubCategories.CategoryID "



    Call OpenDB


    Response.write(""&strSQL&"<br><br>")
    if rsTemp.eof = true then
    Response.write("error")
    Else
    Do while not rsTemp.eof
    strCategoryName = rsTemp("CategoryName")
    %>

    <a href="" onmouseover="window.status='Category'; return true" onmouseout="status='Done'" onclick="showHide('Category'); return false;"><%Response.write(strCategoryName)%></a><br>
    <span id="Category" style="display: none">


    <span onmouseover="window.status='SubCategory'; return true" onmouseout="status='Done'">&nbsp;&nbsp;&nbsp;&nbsp;SubCategory</span><br>

    </span>

    <%
    rsTemp.movenext
    loop

    End if

    Call CloseDB
    Response.write("</body>")
    Response.write("</html>")

    %>

    it lists all the categories from the database, but as soon as I change the SQL statement to left join my sub categories table, i get an error......which is preventing me from displaying the subcategory names when i click a link

    Thanks in advance
    daz
    Last edited by DAZW1; 20 Aug 2007 at 03:28 PM. Reason: applying script so far

Similar Threads

  1. Nested Horizontal Menu
    By jeffreymerrell in forum Web Design, HTML Reference and CSS
    Replies: 0
    Last Post: 27 Apr 2006, 03:12 PM

Posting Permissions

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