PDA

View Full Version : DB driven tree menu



DAZW1
20 Aug 2007, 01:01 PM
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