树型菜单的JS实现的一个解决方案

时间:2010-04-12 12:27:20  来源:第二电脑网  作者:第二电脑网

  第二电脑网导读:.style.display = ""; } else { obj.style.display = "none" } } else { lastObj.style.display = "none"; obj.style.display = ""; } } else { obj.style.display = ""; } lastObj = obj } </SCRIPT&g...
  正文:<SCRIPT language="JavaScript">
var lastObj

function expandIt(obj)
{
if(lastObj != null)
{
if(obj == lastObj)
{
if(obj.style.display == "none")
{
obj.style.display = "";
}
else
{
obj.style.display = "none"
}
}
else
{
lastObj.style.display = "none";
obj.style.display = "";
}
}
else
{
obj.style.display = "";
}

lastObj = obj
}
</SCRIPT>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<%
dim id
id = request("id")
dim strsql,rs

strsql="select * from p_type where slanguage=1 and typelevel=1 order by typename"
set rs=fgetrslist(strsql)
do while not rs.eof

%>
<tr>
<td height="25" class="LEFTLINKS"><img width="30" height="0" align="absmiddle" /><b><%if rs("isleaf")=0 then%><a href="#" onClick="javascript:expandIt(kb<%=rs("id")%>);return false"><%else%><a href="<%=request.ServerVariables("SCRIPT_NAME")%>?idtree=<%=rs("idtree")%>" ><%end if%><%=server.HTMLEncode(right((rs("typename")&""),len(rs("typename")&"")-2))%></a></b></td>
</tr>
<%
IF clng(id)=clng(rs("id")) then

%>
<tr id="kb<%=rs("id")%>">
<%
else

%>


<tr id="kb<%=rs("id")%>" style="display:none;">
<%
end if
%>
<td>
<table>
<%
dim rs1
strsql="select * from p_type where parentid="&rs("id")&" and slanguage=1 order by typename"
set rs1=fgetrslist(strsql)
do while not rs1.eof
%>
<tr><td height="20" class="LEFTLINKS">
<img width="40" height="0" align="absmiddle" /><a href="<%=request.ServerVariables("SCRIPT_NAME")%>?idtree=<%=rs1("idtree")%>&id=<%=rs("id")%>" ><%=server.HTMLEncode(right((rs1("typename")&""),len(rs1("typename")&"")-2))%></a></td></tr>
<%
rs1.movenext
loop
rs1.close
set rs1=nothing
%>
</table>
</td>
</tr>
<%
rs.movenext

loop
rs.close
set rs=nothing
%>
</table> 《树型菜单的JS实现的一个解决方案》由第二电脑网原创提供,转载请注明:http://www.002pc.com/master/College/Programming/JavaScript/13592.html


关键字:

关于《树型菜单的JS实现的一个解决方案》文章的评论

站内搜索: 高级搜索

热门搜索: Windows style 系统 tr IP QQ CPU 安装 function 注册 if td