ASP通过递归方法实现无限级树
|
Ccoffee
2012年3月5日 14:10
本文热度 2701
|
<!--#include file ="Admin_Start.asp"-->
<%
CallTreeView(0,"XR_News_Sort_List","Admin_News_Info_List.asp")
%>
<%
'////////////////////////////判断菜单下属是否存在子菜单
Function CheckDown(ParentId,TableName)
Set Rs_Temps =Server.CreateObject("ADODB.RecordSet")
Rs_Temps.Open "select Sort_Id from"&TableName&" where Sort_Up ="&Int(ParentId),Conn,1,3
If Rs_Temps.Eof And Rs_Temps.Bof Then
CheckDown = false
Else
CheckDown = true
End If
Set Rs_Temps = Nothing
End Function
'////////////////////////////////////////显示树形结构
Function TreeView(ParentId,TableName,Url)
Set Rs_Temp =Server.CreateObject("ADODB.RecordSet")
Rs_Temp.Open "select Sort_Id,Sort_Name,Sort_Numfrom "&TableName&" where Sort_Up ="&Int(ParentId)&" order by Sort_Num",Conn,1,3
%>
<table>
<%
If Not(Rs_Temp.Eof And Rs_Temp.Bof) Then
Do While Not Rs_Temp.Eof
Flag = CheckDown(Rs_Temp(0),TableName)
If Flag = false Then
%>
<tr onMouseOver="this.style.background='#ebebeb';"onMouseOut="this.style.background='#ffffff';">
<td height="30" align="left"style="padding-left:10px">
<img src="images/minus.gif" width="15"height="15" align="absmiddle" alt="点击展开信息列表">
<input type="text" size="2" align="absbottom"name="txtNews<%=Rs_Temp(0)%>" value="<%=Rs_Temp(2)%>"/><a href="<%=Url%>?id=<%=Rs_Temp(0)%>"target="right"><%=Rs_Temp(1)%></a></td>
</tr>
<%
Else
%>
<tr onMouseOver="this.style.background='#ebebeb';"onMouseOut="this.style.background='#ffffff';">
<td height="30" align="left"style="padding-left:10px">
<img src="images/plus.gif" width="15"height="15" align="absmiddle" alt="点击展开信息列表"onClick="opencat(cat_<%=Rs_Temp(0)%>,this)"style="cursor:hand" >
<input type="text" size="2" align="absbottom"name="txtGoods<%=Rs_Temp(0)%>" value="<%=Rs_Temp(2)%>"/><%=Rs_Temp(1)%></td>
</tr>
<tr onMouseOver="this.style.background='#ebebeb';"onMouseOut="this.style.background='#ffffff';">
<tr id="cat_<%=Rs_Temp(0)%>"style="display:none;">
<td><%CallTreeView(Rs_Temp(0),TableName,Url)%></td>
</tr>
<%
End If
Rs_Temp.MoveNext
Loop
End If
%>
</tr>
<%
Set Rs_Temp = Nothing
%>
</table>
<%
End Function
%>
<!--#include file = "Admin_End.asp"-->
该文章在 2012/3/5 14:10:06 编辑过