Kosmisk tilretning af menu
Jeg har fået tilrettet nedenstående menu via eksperten og er stødt på et lille kosmetisk problem, som jeg ønsker hjælp til...Problemet er kort fortalt, at hvis der er åbnet et menu punkt på niveau 2 med et underpunkt og herefter klikkes på et andet punkt på niveau 2 skal den lukke det første, men det sker ikke og jeg kan ikke lige gennemskue, hvor det går galt.
+ 1. Niveau 1
+ 1. Niveau 2
• 1. Niveau 3
• 2. Niveau 3
• 2. Niveau 2 (Så er det hvis der klikkes her, skal
ovenstående menupunkt lukkes)
• 3. Niveau 2
• 2. Niveau 1
**********************************************************
<!-- #INCLUDE FILE="inc.asp" -->
<%
l_language=request.querystring("l_language")
' assigns the variable u_number to the value
' that u_value contains in the url
%>
<%
varLanguage=request.form("l_language")
%>
<HTML>
<HEAD>
<LINK rel="stylesheet" type="text/css" href="style.css">
<title>Links <%= l_language%></title>
<base target="main">
<SCRIPT>
foer = null;
function highlight(lnk) {
if (foer){
foer.style.color = "";
foer.style.fontWeight = "";
}
lnk.style.color = "#FFFF00";
lnk.style.fontWeight = "bold";
foer = lnk;
}
</SCRIPT>
<SCRIPT>
function MenuClick(tal) {
var tal_str = "" + tal
var tal_arr = tal_str.split(",")
var y = document.getElementById("txt_" + tal_arr[0]);
var lukket = true;
if(y.style.display == ''){
lukket = false;
}
LukMenu();
if(lukket){
y.style.display = '';
document.getElementById(tal_arr[0]).src = 'images/minus.gif';
}
for (i=1; i<tal_arr.length; i++){
var txt = document.getElementById("txt_" + tal_arr[i]);
txt.style.display = '';
var img = document.getElementById(tal_arr[i]);
img.src = 'images/minus.gif';
}
}
function LukMenu(){
var x=document.getElementsByTagName("DIV")
for (i = 0; i < x.length; i++){
x[i].style.display = 'none'
}
x = document.getElementsByTagName("IMG")
for (i = 0; i < x.length; i++){
var src_arr = x[i].src.split("/")
if (src_arr[src_arr.length-1] == 'minus.gif'){
x[i].src = 'images/plus.gif'
}
}
}
</SCRIPT>
</HEAD>
<body class="menuda" leftmargin="0" rightmargin="0" bottommargin="0" marginwidth="0" marginheight="0">
<table border="0" style="border-collapse: collapse" width="100%" id="table2" cellpadding="0">
<tr>
<td height="124" align="left" valign="top">
<%
Dim varLanguage
varLanguage = l_language
Function BygMenu(MenuID)
OverSQL = "SELECT ID, Name, Link, User, Target, Language, Description FROM Menu WHERE MenuID = -1 and Language= ('" & varLanguage & "') ORDER BY [Order]"
Call OpenRS(Conntemp,OverSQL,UnderRS)
While Not UnderRS.EOF
If RS("Name") = "<HR>" Then
response.write "<B><hr></B>"&vbCrLf
Else
Response.Write "<A class=menu" & varUser & " HREF=""" & UnderRS("Link") & " OnClick=""highlight(this);LukMenu();"" TARGET="""">" & UnderRS("Name") & ""
Response.Write "<A HREF=""#"" OnClick=""MenuClick('" & UnderRS("ID") & "," & Liste & "');highlight(this);"">" & UnderRS("Name") & "</B></A><BR>"&vbCrLf
End If
UnderRS.MoveNext
Wend
End Function
Function BygUnderMenu(MenuID,Liste)
UnderSQL = "SELECT ID, Name, Link, User, Target, Language, Description FROM Menu WHERE MenuID = " & MenuID & " and Language= ('" & varLanguage & "') ORDER BY [Order]"
Call OpenRS(Conntemp,UnderSQL,UnderRS)
Response.Write "<DIV ID=""txt_" & MenuID & """ STYLE=""display: none; margin-left: 10px;"">"&vbCrLf
While Not UnderRS.EOF
If CountSubs(UnderRS("ID")) > 0 Then
Response.Write "<A class=menuda HREF=""" & UnderRS("Link") & """ OnClick=""MenuClick('" & UnderRS("ID") & "," & Liste & "');highlight(this);""><img id="""&UnderRS("ID")&""" src=""images/plus.gif"" width=13 height=12 border=0 align=""left"">" & UnderRS("Name") & "</A>"&vbCrLf
Liste = UnderRS("ID") & "," & Liste
Call BygUnderMenu (UnderRS("ID"), Liste)
'Til hvert underkald fjernes hovedet af listen så rekursiviteten kører
temp = Split(Liste,",")
if UBound(temp) > 0 then
nyListe = ""
temp = Split(Liste,",")
for t=1 to UBound(temp)
if t=1 then
nyListe = temp(t)
else
nyListe = nyListe &","& temp(t)
end if
next
Liste = nyListe
else
Liste = MenuID
end if
Else
If UnderRS("Name") = "<HR>" Then
response.write "<B><hr></B>"&vbCrLf
else
Response.Write "<A class=menuda OnClick=""highlight(this);"" HREF=""" & UnderRS("Link") & """ TARGET=""" & UnderRS("Target") & """><img src=""images/leaf.gif"" width=13 height=12 border=0 align=""left"">" & UnderRS("Name") & "</A>"&vbCrLf
End If
End If
UnderRS.MoveNext
Wend
Response.Write "</DIV>"
End Function
Function CountSubs(MenuID)
CountSQL = "SELECT ID, User, Language FROM Menu WHERE MenuID = " & MenuID & " and Language= ('" & varLanguage & "')"
Call OpenRS(Conntemp,CountSQL,CountRS)
CountSubs = CountRS.RecordCount
End Function
LavDatabase Conntemp
SQL = "SELECT ID, Name, Link, User, Target, Language, Description FROM Menu WHERE MenuID = -1 and Language= ('" & varLanguage & "') ORDER BY [Order]"
Call OpenRS(Conntemp,SQL,RS)
If RS.BOF AND RS.EOF Then
Response.Write "Ingen data"
Else
RS.MoveFirst
While Not RS.EOF
If RS("Name") = "<HR>" Then
response.write "<B><hr></B>"&vbCrLf
Else
If CountSubs(RS("ID")) > 0 Then
Response.Write "<A class=menuda HREF=""" & RS("Link") & """ TARGET=" & RS("Target") & " OnClick=""MenuClick(" & RS("ID") & ");highlight(this);""><img id="""&RS("ID")&""" src=""images/plus.gif"" width=13 height=12 border=0 align=""left"">" & RS("Name") & "</A>"&vbCrLf
Call BygUnderMenu (RS("ID"),RS("ID"))
Else
Response.Write "<A class=menuda OnClick=""highlight(this);LukMenu();"" HREF=""" & RS("Link") & """><img src=""images/leaf.gif"" width=13 height=12 border=0 align=""left"">" & RS("Name") & "</A>"&vbCrLf
End If
End If
RS.MoveNext
Wend
End If
LukDatabase Conntemp
Response.Write "</center><br></font><font size=""1"">"
%>
</td>
</tr>
</table>
</BODY>
</HTML>
