求树形菜单单击先关闭之前打开的菜单,再打开当前菜单的代码
求树形菜单单击先关闭之前打开的菜单,再打开当前菜单的代码,就是说不能同时打两个同级菜单,求完整代码,
以下是我本人原来的代码,
<table border="0" width="100%" height="200" cellspacing="0" cellpadding="0">
<tr>
<td width="20%" height="200" bgcolor="#F0F0F0" valign=top>
<script language="JavaScript">
<!--
function showLay(divId){
var objDiv = eval(divId);
if (objDiv.style.display=="none"){
eval("sp"+divId+".innerHTML='-'");
objDiv.style.display="";
}else{
eval("sp"+divId+".innerHTML='+'");
objDiv.style.display="none";
}
}
</script>
<%
dim rsTEMP,sqlTEMP
bigclassname = request("bigclassname")
smallclassname = request("smallclassname")
'set rsTEMP= Server.CreateObject("ADODB.Recordset")
' sqlTEMP="select * from aboutus where Newsid<>'' and newsclass='"&class1&"' order by newstop,Newsid asc"
' rsTEMP.Open sqlTEMP,conn,1,1
sql="select id,class from aboutusclass"
set rs=conn.execute(sql)
counter=0 '---------------------------------------------------------------------A COUNTER USED
menucount=0
while not rs.eof
counter=counter+1
sqlTEMP="select newsheadline from aboutus where newsclass='"&rs("class")&"'"
set rsTEMP=conn.execute(sqlTEMP)
if bigclassname<>rs("class") then
%>
<a href="#" onClick="showLay('Layer<%=counter%>')"><span id="spLayer<%=counter%>"><img src="img/menudot.GIF" width="3" height="11"></span></a><a href="#" onClick="showLay('Layer<%=counter%>')"><%=rs("class")%></a><br>
<div id="Layer<%=counter%>" style="display:none;">
<%while not rsTEMP.eof%>
|-<a href="bookincategory.asp?bigclassname=<%=rs("class")%>&smallclassname=<%=rsTEMP("newsheadline")%>"> <%=rsTEMP("newsheadline")%></a><br>
<%
rsTEMP.movenext
wend
else
%>
<a href="#" onClick="showLay('Layer<%=counter%>')"><span id="spLayer<%=counter%>">-</span><%=rs("class")%></a><br>
<div id="Layer<%=counter%>">
<%while not rsTEMP.eof%>
|-<a href="bookincategory.asp?bigclassname=<%=rs("class")%>&smallclassname=<%=rsTEMP("newsheadline")%>"> <%=rsTEMP("newsheadline")%></a><br>
<%
rsTEMP.movenext
wend
end if
menucount=counter
%>
</div>
<%
rs.movenext
wend
%>
</div></td>
</tr>
</table>