Here is my code:

I have my code setup to write out the menu dynamically.
It builds the second teer, the problem is getting the third teer to show and hide to it's appropriate parent section.

[CODE]
dim dhtml_cats_menu_sql

sub request_dhtml_cats_menu
MenuContentType = request("MenuContentType")
MenuParentId = request("MenuParentId")
MenuMenuLabel = request("MenuMenuLabel")
MenuDefaultURL = request("MenuDefaultURL")
MenuCatID = request("MenuCatID")
MenuSubCatId = request("MenuSubCatId")
MenuSubCat = request("MenuSubCat")
MenuCat = request("MenuCat")
end sub

sub validate_dhtml_cats_menu
''' request and validate data entered from this form
MenuContentType = trim(request("MenuContentType"))
MenuParentId = trim(request("MenuParentId"))
MenuMenuLabel = trim(request("MenuMenuLabel"))
MenuDefaultURL = trim(request("MenuDefaultURL"))
MenuCatID = trim(request("MenuCatID"))
MenuSubCatId = trim(request("MenuSubCatId"))
MenuSubCat = trim(request("MenuSubCat"))
MenuCat = trim(request("MenuCat"))
end sub


sub db_select_dhtml_cats_menu
dhtml_cats_menu_sql = "SELECT " & _
"Cats.Cat AS MenuCat, " & _
"Cats.CatId AS MenuCatId," & _
"SubCats.Cat AS MenuSubCat," & _
"SubCats.CatId AS MenuSubCatId," & _
"SubCats.ParentId AS MenuParentId," & _
"Cats.CatTypeId," & _
"DefaultURL AS MenuDefaultURL," & _
"MenuLabel AS MenuMenuLabel, " & _
"ContentType AS MenuContentType " & _
"FROM ((ContentTypes LEFT JOIN Cats ON Cats.CatTypeId=ContentTypes.CatTypeId) LEFT JOIN Cats AS SubCats ON SubCats.ParentId = Cats.CatId) " & _
"WHERE ContentTypes.Enabled=1 AND (ContentTypes.HideMenu=0 or ContentTypes.HideMenu IS NULL) ORDER BY ContentTypes.DisplayOrder, Cats.DisplayOrder, Cats.Cat, SubCats.DisplayOrder, SubCats.Cat"


end sub


':: request action
action = lcase(request("action"))

':: handle the action
select case action

case "select_dhtml_cats_menu"
' select the requested key record from database
db_select_dhtml_cats_menu


end select

':: handle the default case(s) (ignores value of action parameter)
db_select_dhtml_cats_menu

%>

<script type="text/javascript" src="common/i_dhtmlmenu.js"></script>
<script type="text/javascript">
<!--
window.onload = function() {
initializeMenu("1menu", "1actuator");
initializeMenu("2menu", "2actuator");
initializeMenu("3menu", "3actuator");
initializeMenu("4menu", "4actuator");
initializeMenu("5menu", "5actuator");
initializeMenu("6menu", "6actuator");
initializeMenu("7menu", "7actuator");
initializeMenu("8menu", "8actuator");
initializeMenu("9menu", "9actuator");
initializeMenu("10menu", "10actuator");
}
//-->
</script>
<%

SavedContentType=ContentType
ctr = 0

':: display related and/or sibling categories
if CatId <> "" then
CatId = cInt(CatId)
rsql="SELECT Cats.CatId AS CatId0, Cats1.CatId AS CatId1, Cats2.CatId AS CatId2, Cats3.CatId AS CatId3, Cats3.ParentId As ParentId3, Cats4.CatId AS CatId4, Cats4.ParentId As ParentId4, Cats5.CatId AS CatId5, Cats5.ParentId As ParentId5, ContentType FROM ((((((ContentTypes RIGHT JOIN Cats As Cats5 ON Cats5.CatTypeId = ContentTypes.CatTypeId) LEFT JOIN Cats As Cats4 ON Cats5.ParentId = Cats4.CatId) LEFT JOIN Cats As Cats3 ON Cats4.ParentId = Cats3.CatId) LEFT JOIN Cats As Cats2 ON Cats3.ParentId = Cats2.CatId) LEFT JOIN Cats As Cats1 ON Cats2.ParentId = Cats1.CatId) LEFT JOIN Cats ON Cats1.ParentId = Cats.CatId) WHERE Cats5.CatId = " & to_sql(CatId,"number")

set rs = cn.Execute(rsql)
if not rs.EOF then
CatId0=rs(0)
CatId1=rs(1)
CatId2=rs(2)
CatId3=rs(3)
ParentId3 =rs(4)
CatId4=rs(5)
ParentId4 =rs(6)
CatId5=rs(7)
ParentId5 =rs(8)
ContentType = rs(9)
end if
rs.Close
end if

%>
<%

page_no = request("page_no")
if page_no = "" then page_no = 1

if dhtml_cats_menu_sql <> "" then
cmd.CommandText = dhtml_cats_menu_sql
rs.Filter = ""
rs.CursorLocation = 3
rs.CacheSize = 5
rs.Open cmd
if not rs.EOF then
rs.MoveFirst
num_recs = rs.RecordCount
results = true
else
results = false
rs.Close
end if
else
results = false
end if
rec_count = 0

%>

<%

if results = true then



%>

<div 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")
MenuCat = rs("MenuCat")
MenuSubCatId = rs("MenuSubCatId")
MenuSubCat = rs("MenuSubCat")

on error goto 0

%>
<% if LastMenuContentType <> MenuContentType then %>
<%
if LastMenuContentType<>"" then
response.write "</ul></li>"
else
response.write "<ul id='DhtmlMenu'>"
end if
%>
<li class="dhtml">
<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 LastMenuSubCat <> MenuSubCat or Show then %>


<li class="dhtml"> <A href='content.do?CatId=<% =MenuCatId %>'> <% =MenuCat%> </li>



</A>





<li class="DhtmlMenuItemSub"> <A href='content.do?subCatId=<% =MenuSubCatId %>'> <% =MenuSubCat%> </A></li></li>



<%

show = FALSE
end if

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

%>


<%

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

%>


</div>