Print Page | Close Window

Highlight Active Catagory

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=14713
Printed Date: 30 March 2026 at 6:30am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Highlight Active Catagory
Posted By: Lucent
Subject: Highlight Active Catagory
Date Posted: 15 April 2005 at 7:27pm

This code is for catagory tree menu. For example.

Woman
    Handbag
    Top
    Pants
       
Man
    Belt
    Pants
    Suite
 
And whenever I'm in the catagory, the menu would stay open, and close other catagory.

My question is how can I modify this code so not only the active catagory would stay open, but it would also change the style of the catagory (background color, highlight the selected sub catagory, etc)
any help would be great, thank you!!

----------------code-------------------
<script>
 function UpDown(tabid)
 {
 var etab=eval(tabid);
  if (etab.style.display=='')
  { etab.style.display='none';
  }
  else
  { etab.style.display='';
  }
 }
</script>
<%
Dim CATsTmp(4)
Dim pcv_ToTalCAT
CATsTmp(0)=0
CATsTmp(1)=0
CATsTmp(2)=0
CATsTmp(3)=0
pcv_TotalCAT=0
dim conn, rsMenuObj
Set conn=Server.CreateObject("ADODB.Connection")
conn.Open scDSN
if pcv_ShowAllCATs=1 then
 IF pcv_checkPageCat<>"" then
  HaveParent=1
  CATsTmp(0)=pcv_checkPageCat
  pcv_TotalCAT=1
  pcv_idcatTmp=pcv_checkPageCat
  do while HaveParent=1
   query="select idParentCategory from categories where idcategory=" & pcv_idcatTmp
   set rsMenuObj=server.CreateObject("ADODB.RecordSet")
   set rsMenuObj=conn.execute(query)
   
   if not rsMenuObj.eof then
    pcv_idcatTmp=rsMenuObj("idParentCategory")
    if pcv_idcatTmp="1" then
     HaveParent=0
    else
     pcv_TotalCAT=pcv_TotalCAT+1
     CATsTmp(pcv_TotalCAT-1)=pcv_idcatTmp
     HaveParent=1
    end if
   else
    HaveParent=0
   end if
  loop
  set rsMenuObj=nothing
 ELSE
  IF pcv_CheckPagePrd<>"" then
   query="select idcategory from categories_products where idproduct=" & pcv_CheckPagePrd
   set rsMenuObj=conn.execute(query)
   if not rsMenuObj.eof then
    HaveParent=1
    CATsTmp(0)=rsMenuObj("idcategory")
    pcv_TotalCAT=1
    pcv_idcatTmp=rsMenuObj("idcategory")
    do while HaveParent=1
     query="select idParentCategory from categories where idcategory=" & pcv_idcatTmp
     set rsMenuObj=server.CreateObject("ADODB.RecordSet")
     set rsMenuObj=conn.execute(query)
   
     if not rsMenuObj.eof then
      pcv_idcatTmp=rsMenuObj("idParentCategory")
      if pcv_idcatTmp="1" then
       HaveParent=0
      else
       pcv_TotalCAT=pcv_TotalCAT+1
       CATsTmp(pcv_TotalCAT-1)=pcv_idcatTmp
       HaveParent=1
      end if
     else
      HaveParent=0
     end if
     set rsMenuObj=nothing
    loop
   end if
  END IF
 END IF
end if

Function CheckCAT(catID)
 if pcv_TotalCAT>0 then
  For i=1 to pcv_TotalCAT
   if clng(catID)=clng(CATsTmp(i-1)) then
    CheckCAT=""
    exit for
   else
    CheckCAT=" style=""display:none"" "
   end if
  Next
 else
  CheckCAT=" style=""display:none"" "
 end if
End Function
%>
<%
If Session("customerType")=1 Then
 pcv_strTemp=""
else
 pcv_strTemp=" AND pccats_RetailHide<>1 "
end if
'----- Start Categories Level 1
query="select idcategory,categorydesc from categories where idParentCategory=1 and idCategory>1 and iBTOhide=0 " & pcv_strTemp & " ORDER BY priority, categoryDesc ASC"
set rsMenuObj=server.CreateObject("ADODB.RecordSet")
set rsMenuObj=conn.execute(query)
 
IF not rsMenuObj.eof then
 response.write "<table border=""0"" width=""100%"" cellpadding=""0"" cellspacing=""0"">" & vbcrlf
 do while not rsMenuObj.eof
  IDCategory1=rsMenuObj("idcategory")
  CatDesc1=rsMenuObj("categorydesc")
  
  '----- Start Categories Level 2
  query="select idcategory,categorydesc from categories where idParentCategory=" & IDCategory1 & " and idCategory>1 and iBTOhide=0 " & pcv_strTemp & " ORDER BY priority, categoryDesc ASC"
  set rsMenuObj2=server.CreateObject("ADODB.RecordSet")
  set rsMenuObj2=conn.execute(query)
 
  IF not rsMenuObj2.eof then
   response.write "<tr><td style=""padding-left: 8px;"" bgcolor=""#6A6A6A"" height=""25"" class=""boxframetopbottom1"">" & vbcrlf
   response.write "<strong><Font color=""#ffffff""><a href=""javascript:UpDown('SUB" & IDCategory1 & "')"" class=""HLlinkW"">" & CATDesc1 & "</a></font></strong></td></tr>" & vbcrlf
   response.write "<tr><td><table width=""100%""  cellspacing=""0"" cellpadding=""0"" " & CheckCat(IDCategory1) & " id=""SUB" & IDCategory1 & """ bgcolor=""#CCCCCC"" class=""boxframetopbottom"">" & vbcrlf
   do while not rsMenuObj2.eof
    IDCategory2=rsMenuObj2("idcategory")
    CatDesc2=rsMenuObj2("categorydesc")
  
    '----- Start Categories Level 3
    query="select idcategory,categorydesc from categories where idParentCategory=" & IDCategory2 & "  and idCategory>1 and iBTOhide=0 " & pcv_strTemp & " ORDER BY priority, categoryDesc ASC"
    set rsMenuObj3=server.CreateObject("ADODB.RecordSet")
    set rsMenuObj3=conn.execute(query)
 
    IF not rsMenuObj3.eof then
     response.write "<tr><td style=""padding-left: 16px;"" height=""20"" bgcolor=""#8F8F8F"">" & vbcrlf
     response.write "<a href=""javascript:UpDown('SUB" & IDCategory2 & "')"" class=""HLlink"">" & CATDesc2 & "</a></td></tr>" & vbcrlf
     response.write "<tr><td><table width=""100%"" cellpadding=""0"" cellspacing=""0"" " & CheckCat(IDCategory2) & " id=""SUB" & IDCategory2 & """>" & vbcrlf
     do while not rsMenuObj3.eof
      IDCategory3=rsMenuObj3("idcategory")
      CatDesc3=rsMenuObj3("categorydesc")
    &



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net