469,271 Members | 1,014 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

Still problems with my menu...

Hi again!

now I realy have a problem..

I want om make a menu that expandes like the menu on http://www.eks.as

The menu should expand after a sertain ID in the querystring. The page you
are on should be bold..

The code works fine exept when I pass a ID that belongs to a "child" in the
menu.... Any idea???
here's what I got so far....

<html>
<head>
<title>default.asp</title>
</head>

<body>

<%
' Connection to the database / Datenbankverbindung
Dim ConnectString, conn
ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("../../Documents and Settings/All
Users/Dokumenter/portal.mdb")
Set conn = Server.CreateObject("ADODB.Connection")
conn.open ConnectString
%>

<%DIm ID
ID = Request.Querystring("id") %>
<%
'Henter kategorier
Dim sqlMeny, rsMeny
sqlMeny = "SELECT * FROM Meny ORDER BY ID ASC"
Set rsMeny = Server.CreateObject("ADODB.Recordset")
rsMeny.Open sqlMeny, conn, 3, 3
do until rsMeny.Eof
If rsMeny("parent") = 0 Then
%>
<%= rsMeny("Navn") %><br>
<%
Else
End If
If CInt(rsMeny.Fields("ID").Value) = CInt(ID) Then

'Henter kategorier
Dim sqlUnder, rsUnder
sqlUnder = "SELECT * FROM Meny WHERE Parent = "& rsMeny("id") &" ORDER BY ID
ASC"
Set rsUnder = Server.CreateObject("ADODB.Recordset")
rsUnder.Open sqlUnder, conn, 3, 3
do until rsUnder.Eof
%>

--<%= rsUnder("Navn") %><br>

<%
rsUnder.MoveNext
Loop
Else
End If

%>
<%
rsMeny.MoveNext
Loop
'disconnect
conn.close
Set conn = Nothing
%>

</body>
</html>


Christopher Brandsdal
Norway
Jul 19 '05 #1
1 1651
http://www.aspfaq.com/show.asp?id=2096
Dim sSQL
sSQL="SELECT meny.ID, meny.Navn, meny.Parent, " & _
"meny_1.ID AS ChildID, meny_1.Navn AS ChildNavn, " & _
"meny_1.Parent AS ChildParent " & _
"FROM meny LEFT OUTER JOIN " & _
" meny meny_1 ON meny.ID = meny_1.Parent " & _
"WHERE (meny.Parent = 0)"

'The above sql statement will return all parent rows and their children in
this style......
'ID Navn ParentID ChildID ChildNavn ChildParent
'1 text1 0 3 child1 1
'1 text1 0 4 child2 1
'2 text2 0 5 child3 2
'6 text3 0 <null> <null> <null>
' Connection to the database / Datenbankverbindung
Dim ConnectString, conn
ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("../../Documents and Settings/All
Users/Dokumenter/portal.mdb")
Set conn = Server.CreateObject("ADODB.Connection")
conn.open ConnectString
Dim rsMeny
Set rsMeny=conn.Execute(sSQL)
if not rsMeny.eof then
Dim lngCurrentParentID
Dim bChildBold
Dim bParentBold
Dim lngBoldedID

lngBoldedID=Request.QueryString("id")
lngCurrentParentID=0

Do While not rsMeny.EOF
bChildBold=false
bParentBold=false
if lngBoldedID=rsMeny.Fields("ID") then bParentBold=true
if lngBoldedID=rsMeny.Fields("ChildID") then bChildBold=true

if rsMeny.Fields("ID") <> lngCurrentParentID then
'this is the first or the next parent record
if bParentBold then
Response.write "<b>" & rsMeny.Fields("navn") &
"</b>"
else
Response.write rsMeny.Fields("navn")
end if
lngCurrentParentID=rsMeny.Fields("ID")
end if
if len(rsMeny.Fields("ChildNavn") & "")>0 then
'this child record is not null (or empty string)
if bChildBold then
Response.write "<b>" &
rsMeny.Fields("ChildNavn") & "</b>"
else
Response.write rsMeny.Fields("ChildNavn")
end if
end if

rsMeny.MoveNext
Loop
end if
Set rsMeny=nothing
conn.Close
Set conn=Nothing


"Christopher Brandsdal" <ch***********@c2i.net> wrote in message
news:%2***************@TK2MSFTNGP11.phx.gbl...
Hi again!

now I realy have a problem..

I want om make a menu that expandes like the menu on http://www.eks.as

The menu should expand after a sertain ID in the querystring. The page you
are on should be bold..

The code works fine exept when I pass a ID that belongs to a "child" in the menu.... Any idea???
here's what I got so far....

<html>
<head>
<title>default.asp</title>
</head>

<body>

<%
' Connection to the database / Datenbankverbindung
Dim ConnectString, conn
ConnectString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
Server.MapPath("../../Documents and Settings/All
Users/Dokumenter/portal.mdb")
Set conn = Server.CreateObject("ADODB.Connection")
conn.open ConnectString
%>

<%DIm ID
ID = Request.Querystring("id") %>
<%
'Henter kategorier
Dim sqlMeny, rsMeny
sqlMeny = "SELECT * FROM Meny ORDER BY ID ASC"
Set rsMeny = Server.CreateObject("ADODB.Recordset")
rsMeny.Open sqlMeny, conn, 3, 3
do until rsMeny.Eof
If rsMeny("parent") = 0 Then
%>
<%= rsMeny("Navn") %><br>
<%
Else
End If
If CInt(rsMeny.Fields("ID").Value) = CInt(ID) Then

'Henter kategorier
Dim sqlUnder, rsUnder
sqlUnder = "SELECT * FROM Meny WHERE Parent = "& rsMeny("id") &" ORDER BY ID ASC"
Set rsUnder = Server.CreateObject("ADODB.Recordset")
rsUnder.Open sqlUnder, conn, 3, 3
do until rsUnder.Eof
%>

--<%= rsUnder("Navn") %><br>

<%
rsUnder.MoveNext
Loop
Else
End If

%>
<%
rsMeny.MoveNext
Loop
'disconnect
conn.close
Set conn = Nothing
%>

</body>
</html>


Christopher Brandsdal
Norway

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by eternalD3 | last post: by
5 posts views Thread by Aaron | last post: by
4 posts views Thread by dpomt | last post: by
3 posts views Thread by WT | last post: by
3 posts views Thread by =?ISO-8859-1?Q?Jo=E3o_Maia?= | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.