下面是编程之家 jb51.cc 通过网络收集整理的代码片段。
编程之家小编现在分享给大家,也给大家做个参考。
程序调用:
Dim RSS,u
Set RSS = Server.CreateObject("Adodb.RecordSet")
RSS.Open "select ID,fatherID,name from [Select_Menu] order by id",Conn,1,1
Response.Write " - 0.顶级菜单"&GetListTree&""
RSS.Close
%>
数据库结构:
Select_Menu:
id,fatherid,name
fatherid=0,置为顶级菜单
函数:
'无限级分类菜单树Select输出函数
Function GetListTree
Dim Result,i
Redim u(RSS.RecordCount,3)
for i = 1 to RSS.RecordCount
u(i - 1,0) = RSS("ID")
u(i - 1,1) = RSS("fatherID")
u(i - 1,2) = RSS("Name")
RSS.MoveNext
next
'RSS.moveFirst
for i = 0 to uBound(u) - 1
If Int(u(i,1)) = 0 Then
'如果ID=FatherID则定位其父类
if u(i,0)=fatherid then
selected="Selected"
else
selected=""
end if
Result = Result &" ◢ "& u (i,2) &""& vbcrlf & SunSorts(u(i,0),0)
End If
next
GetListTree = Result
End Function
Function SunSorts(who,SunLevel)
Dim selected
Dim Result,i,sp,EndID
for i = 0 to SunLevel
sp = sp &"--"
next
for i = 0 to uBound(u) - 1
If Int(u(i,1)) = Int(who) Then
EndID = u(i,0)
else
EndID = fatherID
End If
next
for i = 0 to uBound(u) - 1
If Int(u(i,1)) = Int(who) Then
If u(i,0) - EndID = 0 Then
Result = Result &""& sp &"┕"& u(i,2) & ""& vbcrlf & SunSorts(u(i,SunLevel + 1)
Else
Result = Result &""& sp &"┝ "& u(i,SunLevel + 1)
End If
End If
next
SunSorts = Result
End Function
%>
以上是编程之家(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。
如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。
总结
如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您喜欢交流学习经验,点击链接加入交流1群:1065694478(已满)交流2群:163560250