I have a couple of questions, please.
Please take a look at the code below and see if you can help me.
I am writing a shopping cart program and my boss decided we need to have a treeview of categories.
The spec says:
If you click a category, it should expand to give you a list of subcategories.
Both categories and subcategories are database fields.
Then if you click on any of the subcategories, it should give you
a bried description of that subcategory field.
If you like it, add it to your cart. If you don't go back to treeview and make another selection.
I could not come with anything easy.
After doing an extensively devouring online resources, I came up with this code.
My two questions are:
1, can you please help make it possible to have more than one subcategory?
So far, I am getting one subcategory per category.
I need to be able to display all the subcategories in the database.
When I go to query analyzer (sql server), all subcategories belonging to a category are displayed.
The second question is, how can I hyperlink the subcategory so it takes me to description page where each category is given a brief description?
A response to any or all of the questions will be greatly appreciated.
If there is a link that can satisfy any or all of the above needs, please let me have that too.
Thanks in advance.
here is the code I have so far:
<form action='treeview.asp' method='post'>
<%
Dim filePath
Dim oConnect
Dim oResult
Dim Racine
Dim Item
Dim catOld
Dim DiscOld
catOld=""
DiscOld=""
Racine=4
Item=0
' ************ Map authors database to physical path
'filePath = Server.MapPath("db1.mdb")
' ************ Create ADO Connection Component to connect with sample database
Set oConnect = Server.CreateObject("ADODB.Connection")
oConnect.Open "dsn=scart"
'************* SQL query for the Category
Set oResult = oConnect.Execute(" select categories.catdescription, products.cname from categories,products where categories.categoryid = products.ccategory order by categories.catdescription " )
do while (Not oResult.eof)
if oResult("catdescription")<> catOld then
if catOld <> "" then
WriteFoot
WriteFoot
end if
'************** Categories **********
WriteHead "My"&Racine&"TreeView",Item, oResult("catdescription") ,0,True,False,"",False
catOld=oResult("catdescription")
Item=Item+1
'************** SubCategories **********
WriteHead "My"&Racine&"TreeView",Item, oResult("cname") ,1,False,False,"",False
DiscOld=oResult("cname")
Item=Item+1
end if
Racine=Racine+1
oResult.MoveNext
loop
WriteFoot
WriteFoot
%>
</form>