Loop gennem menu system med sub menuer og <div>
HejJeg har følgende til at vise mine websider:
page_id - som er hver sides ID.
parent_page_id - som som er ID'en på den forrige side.
order - som er sidernes rækkefølge i hver menu/sub-menu
title - som er sidernes tittel.
Jeg vil gerne have skrevet noget lign. det efterfølgende eks. ud med response.write så det kommer til at stå rigtig.
Problemet er <DIV> som jeg får sat forkert når jeg looper ned igennem sub menuerne.
eks.:
<DIV class=menuBar style='WIDTH: 80%'>
<A class=menuButton onmouseover="buttonMouseover(event, 'Home');" onclick="return buttonClick(event, 'Home');" HREF=Home>Home</A>
<A class=menuButton onmouseover="buttonMouseover(event, 'webhotel');" onclick="return buttonClick(event, 'webhotel');" HREF=webhotel>webhotel</A>
<A class=menuButton onmouseover="buttonMouseover(event, 'Kontakt');" onclick="return buttonClick(event, 'Kontakt');" HREF=Kontakt>Kontakt</A>
<A class=menuButton onmouseover="buttonMouseover(event, 'Service');" onclick="return buttonClick(event, 'Service');" HREF=Service>Service</A>
<A class=menuButton onmouseover="buttonMouseover(event, 'Domaene');" onclick="return buttonClick(event, 'Domaene');" HREF=Domaene>Domaene</A>
<A class=menuButton onmouseover="buttonMouseover(event, 'webCMS');" onclick="return buttonClick(event, 'webCMS');" HREF=webCMS>webCMS</A>
<A class=menuButton onmouseover="buttonMouseover(event, 'Revilution');" onclick="return buttonClick(event, 'Revilution');" HREF=Revilution>Revilution</A>
</DIV>
<DIV class=menu id=Home onmouseover=menuMouseover(event)></DIV>
<DIV class=menu id=webhotel onmouseover=menuMouseover(event)></DIV>
<DIV class=menu id=Kontakt onmouseover=menuMouseover(event)>
<A class=menuItem HREF="default.asp?active_page_id=30" TARGET="_self">Betingelser</A>
<DIV class=menu id=Betingelser ></DIV>
</DIV>
<DIV class=menu id=Service onmouseover=menuMouseover(event)></DIV><DIV class=menu id=Domaene onmouseover=menuMouseover(event)></DIV><DIV class=menu id=webCMS onmouseover=menuMouseover(event)></DIV><DIV class=menu id=Revilution onmouseover=menuMouseover(event)><A class=menuItem onmouseover="menuItemMouseover(event, 'Konceptet');" onclick="return false;" href=Konceptet><SPAN class=menuItemText>Konceptet</SPAN><SPAN class=menuItemArrow>▶</SPAN></A><DIV class=menu id=Konceptet><A class=menuItem HREF="default.asp?active_page_id=37" TARGET="_self">Sikkerhed</A><DIV class=menu id=Sikkerhed></DIV><A class=menuItem HREF="default.asp?active_page_id=38" TARGET="_self">Teknik</A><DIV class=menu id=Teknik></DIV><A class=menuItem HREF="default.asp?active_page_id=39" TARGET="_self">Livsstil</A><DIV class=menu id=Livsstil></DIV></DIV><A class=menuItem onmouseover="menuItemMouseover(event, 'Loesninger');" onclick="return false;" href=Loesninger><SPAN class=menuItemText>Loesninger</SPAN><SPAN class=menuItemArrow>▶</SPAN></A><DIV class=menu id=Loesninger><A class=menuItem HREF="default.asp?active_page_id=40" TARGET="_self">Bascic_Moduler</A><DIV class=menu id=Bascic_Moduler></DIV><A class=menuItem HREF="default.asp?active_page_id=41" TARGET="_self">Fremtidige</A><DIV class=menu id=Fremtidige></DIV></DIV><A class=menuItem onmouseover="menuItemMouseover(event, 'Ny_bruger');" onclick="return false;" href=Ny_bruger><SPAN class=menuItemText>Ny_bruger</SPAN><SPAN class=menuItemArrow>▶</SPAN></A><DIV class=menu id=Ny_bruger><A class=menuItem HREF="default.asp?active_page_id=42" TARGET="_self">Betingelser</A><DIV class=menu id=Betingelser></DIV></DIV><A class=menuItem HREF="default.asp?active_page_id=44" TARGET="_self">Priser</A><DIV class=menu id=Priser></DIV><A class=menuItem HREF="default.asp?active_page_id=35" TARGET="_self">Presse</A><DIV class=menu id=Presse></DIV></DIV>
<P><!-- Menu bar. --></P>
<DIV class=menuBar style="WIDTH: 80%">
<A class=menuButton onmouseover="buttonMouseover(event, 'fileMenu');" onclick="return buttonClick(event, 'fileMenu');" href="http://">File</A>
<A class=menuButton onmouseover="buttonMouseover(event, 'editMenu');" onclick="return buttonClick(event, 'editMenu');" href="http://">Edit</A>
<A class=menuButton onmouseover="buttonMouseover(event, 'viewMenu');" onclick="return buttonClick(event, 'viewMenu');" href="http://">View</A>
<A class=menuButton onmouseover="buttonMouseover(event, 'toolsMenu');" onclick="return buttonClick(event, 'toolsMenu');" href="http://">Tools</A>
<A class=menuButton onmouseover="buttonMouseover(event, 'optionsMenu');" onclick="return buttonClick(event, 'optionsMenu');" href="http://">Options</A>
<A class=menuButton onmouseover="buttonMouseover(event, 'helpMenu');" onclick="return buttonClick(event, 'helpMenu');" href="http://">Help</A>
</DIV>
<!-- File Under menus. -->
<DIV class=menu id=fileMenu onmouseover=menuMouseover(event)>
<A class=menuItem href="http://blank.html">File Menu Item 1</A>
<A class=menuItem onmouseover="menuItemMouseover(event, 'fileMenu2');" onclick="return false;" href="http://"><SPAN class=menuItemText>File Menu Item 2</SPAN><SPAN class=menuItemArrow>▶</SPAN></A>
<A class=menuItem href="http://blank.html">File Menu Item 3</A>
<A class=menuItem href="http://blank.html">File Menu Item 4</A>
<A class=menuItem href="http://blank.html">File Menu Item 5</A>
<A class=menuItem href="http://blank.html">File Menu Item 6</A> </DIV>
<!-- File sub menus. -->
<DIV class=menu id=fileMenu2>
<A class=menuItem href="http://blank.html">File Menu 2 Item 1</A>
<A class=menuItem href="http://blank.html">File Menu 2 Item 2</A> </DIV>
<!-- Edit Under menus. -->
<DIV class=menu id=editMenu onmouseover=menuMouseover(event)>
<A class=menuItem href="http://blank.html">Edit Menu Item 1</A>
<A class=menuItem href="http://blank.html">Edit Menu Item 2</A>
<A class=menuItem onmouseover="menuItemMouseover(event, 'editMenu3');" onclick="return false;" href="http://"><SPAN class=menuItemText>Edit Menu Item 3</SPAN><SPAN class=menuItemArrow>▶</SPAN></A>
<A class=menuItem href="http://blank.html">Edit Menu Item 4</A>
<A class=menuItem href="http://blank.html">Edit Menu Item 5</A> </DIV>
<!-- Edit sub menus. -->
<DIV class=menu id=editMenu3 onmouseover=menuMouseover(event)>
<A class=menuItem href="http://blank.html">Edit Menu 3 Item 1</A>
<A class=menuItem href="http://blank.html">Edit Menu 3 Item 2</A>
<A class=menuItem onmouseover="menuItemMouseover(event, 'editMenu3_3');" onclick="return false;" href="http://"><SPAN class=menuItemText>Edit Menu 3 Item 3</SPAN><SPAN class=menuItemArrow>▶</SPAN></A>
<A class=menuItem href="http://blank.html">Edit Menu 3 Item 4</A>
</DIV>
<DIV class=menu id=editMenu3_3>
<A class=menuItem href="http://blank.html">Edit Menu 3-3 Item 1</A>
<A class=menuItem href="http://blank.html">Edit Menu 3-3 Item 2</A>
<A class=menuItem href="http://blank.html">Edit Menu 3-3 Item 3</A>
<A class=menuItem href="http://blank.html">Edit Menu 3-3 Item 4</A>
</DIV>
<!-- View Under menus. -->
<DIV class=menu id=viewMenu>
<A class=menuItem href="http://blank.html">View Menu Item 1</A>
<A class=menuItem href="http://blank.html">View Menu Item 2</A>
<A class=menuItem href="http://blank.html">View Menu Item 3</A> </DIV>
<!-- Tools Under menus. -->
<DIV class=menu id=toolsMenu onmouseover=menuMouseover(event)>
<A class=menuItem onmouseover="menuItemMouseover(event, 'toolsMenu1');" onclick="return false;" href="http://"><SPAN class=menuItemText>Tools Menu Item 1</SPAN><SPAN class=menuItemArrow>▶</SPAN></A>
<A class=menuItem href="http://blank.html">Tools Menu Item 2</A>
<A class=menuItem href="http://blank.html">Tools Menu Item 3</A>
<A class=menuItem onmouseover="menuItemMouseover(event, 'toolsMenu4');" onclick="return false;" href="http://"><SPAN class=menuItemText>Tools Menu Item 4</SPAN><SPAN class=menuItemArrow>▶</SPAN></A>
<A class=menuItem href="http://blank.html">Tools Menu Item 5</A> </DIV>
<!-- Tools sub menus. -->
<DIV class=menu id=toolsMenu1>
<A class=menuItem href="http://blank.html">Tools Menu 1 Item 1</A>
<A class=menuItem href="http://blank.html">Tools Menu 1 Item 2</A>
<A class=menuItem href="http://blank.html">Tools Menu 1 Item 3</A>
<A class=menuItem href="http://blank.html">Tools Menu 1 Item 4</A>
<A class=menuItem href="http://blank.html">Tools Menu 1 Item 5</A>
</DIV>
<DIV class=menu id=toolsMenu4 onmouseover=menuMouseover(event)>
<A class=menuItem href="http://blank.html">Tools Menu 4 Item 1</A>
<A class=menuItem href="http://blank.html">Tools Menu 4 Item 2</A>
<A class=menuItem onmouseover="menuItemMouseover(event, 'toolsMenu4_3');" onclick="return false;" href="http://blank.html"><SPAN class=menuItemText>Tools Menu 4 Item 3</SPAN><SPAN class=menuItemArrow>▶</SPAN></A>
</DIV>
<DIV class=menu id=toolsMenu1>
<A class=menuItem href="http://blank.html">Tools Menu 1 Item 1</A>
<A class=menuItem href="http://blank.html">Tools Menu 1 Item 2</A>
<A class=menuItem href="http://blank.html">Tools Menu 1 Item 3</A>
<A class=menuItem href="http://blank.html">Tools Menu 1 Item 4</A>
<A class=menuItem href="http://blank.html">Tools Menu 1 Item 5</A>
</DIV>
<DIV class=menu id=toolsMenu4_3>
<A class=menuItem href="http://blank.html">Tools Menu 4-3 Item 1</A>
<A class=menuItem href="http://blank.html">Tools Menu 4-3 Item 2</A>
<A class=menuItem href="http://blank.html">Tools Menu 4-3 Item 3</A>
<A class=menuItem href="http://blank.html">Tools Menu 4-3 Item 4</A>
</DIV>
<DIV class=menu id=optionsMenu>
<A class=menuItem href="http://blank.html">Options Menu Item 1</A>
<A class=menuItem href="http://blank.html">Options Menu Item 2</A>
<A class=menuItem href="http://blank.html">Options Menu Item 3</A>
</DIV>
<DIV class=menu id=helpMenu>
<A class=menuItem href="http://blank.html">Help Menu Item 1</A>
<A class=menuItem href="http://blank.html">Help Menu Item 2</A>
<A class=menuItem href="http://blank.html">Help Menu Item 3</A> </DIV>
------------------------------------------------
Jeg har ind til videre følgende kode:
<%
Function BygUnderMenu(parent_page_id)
UnderSQL = "SELECT page_id, title FROM pages WHERE parent_page_id = " & parent_page_id & " ORDER BY [pos]"
Call OpenRS(Conntemp,UnderSQL,UnderRS)
' Under menus
While Not UnderRS.EOF
If CountSubs(UnderRS("page_id")) > 0 Then
Response.Write "<A class=menuItem onmouseover=""menuItemMouseover(event, '" & UnderRS("title") & "');"" onclick=""return false;"" href="& UnderRS("title") &"><SPAN class=menuItemText>" & UnderRS("title") & "</SPAN><SPAN class=menuItemArrow>â–¶</SPAN></A>"
Else
Response.Write "<A class=menuItem HREF=""" & "default.asp?active_page_id=" & UnderRS("page_id") & """ TARGET=""_self"">" & UnderRS("title") & "</A>"
End If
Response.Write "<DIV class=menu id=" & UnderRS("title") & ">"
BygUnderMenu UnderRS("page_id")
Response.Write "</DIV>"
UnderRS.MoveNext
Wend
End Function
Function CountSubs(parent_page_id)
CountSQL = "SELECT page_id FROM pages WHERE parent_page_id = " & parent_page_id & ""
Call OpenRS(Conntemp,CountSQL,CountRS)
CountSubs = CountRS.RecordCount
End Function
LavDatabase Conntemp
SQL = "SELECT page_id, title FROM pages WHERE parent_page_id = 0 ORDER BY [pos]"
Call OpenRS(Conntemp,SQL,RS)
If RS.BOF AND RS.EOF Then
Response.Write "FEJL"
Else
' Menu bar
RS.MoveFirst
Response.Write "<DIV class=menuBar style='WIDTH: 10%'>"
While Not RS.EOF
Response.Write "<A class=menuButton onmouseover=""buttonMouseover(event, '" & RS("title") & "');"" onclick=""return buttonClick(event, '" & RS("title") & "');"" HREF=" & RS("title") & ">" & RS("title") & "</A>"
RS.MoveNext
Wend
Response.Write "</DIV>"
' Main menus
RS.MoveFirst
While Not RS.EOF
Response.Write "<DIV class=menu id=" & RS("title") & " onmouseover=menuMouseover(event)>"
BygUnderMenu RS("page_id")
Response.Write "</DIV>"
RS.MoveNext
Wend
End If
LukDatabase Conntemp
%>
-------------
Det går også fint indtil jeg skal til at lave
BygUnderMenu UnderRS("page_id") , her bliver <DIV> erne blandet sammen.