📄 navtree.asp
字号:
<%
'无限级分类,树状显示代码。
'数据库字段:NS_Id——自动编号;分类ID
' NS_Name——文本;类名
' NS_Parentid——数字;上级ID
' NS_Level——数字;分类级深(无用)
' NS_Order——数字;分类排序
'参数介绍:
' table——要查询的表
' sortid——查找的顶级类ID
' rs——数据集
' tree——树状标志的形状
' selectid——标志为被选中的类的ID
' isclose——是否显示该类的下级分类
' Language——分类语言
sub showtreefornav(table,prefix,sortid,rs,tree,selectid,isclose)
showmore=1
trees="1"
treestr=tree&trees
set rs=server.CreateObject("adodb.recordset")
rs.open"select * from "&table&" where "&prefix&"Parentid="&sortid&" order by "&prefix&"Order,"&prefix&"id",conn,1,1
if rs.eof and tree="" then
response.Write" <option value=''>暂无分类</option>"
else
do while not rs.eof
NS_Name=rs(prefix&"Name")
NS_Id=rs(prefix&"Id")
rs.movenext
if rs.eof then
trees="0"
treestr=tree&trees
end if
if not(isclose=1 and cstr(selectid)="0") then
'显示分类
response.Write vbcrlf&" <option value='"&NS_Id&"'"
if cstr(selectid)=cstr(NS_Id) then
response.write(" selected")
end if
response.write(">")
'显示树状符号
for i=0 to len(treestr)-2
if mid(treestr,i+1,1)="1" then
response.Write("┃")
else
response.Write(" ")
end if
next
if trees="0" then
response.Write"┗"
elseif tree="" then
response.Write"┏"
else
response.Write"┣"
end if
response.Write NS_Name&"</option>"
end if
'判断是否显示该类的下级小类(类不能移动自己的下级类下)
if isclose=1 then
if cstr(selectid)=cstr(NS_Id) or cstr(selectid)="0" then
showmore=0
end if
end if
if showmore=1 then
showtreefornav table,prefix,NS_Id,"rs"&cstr(NS_Id),treestr,selectid,isclose
end if
showmore=1
loop
end if
rs.close
end sub
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -