程序调用:
<%
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 ""
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 &""& 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 &""& vbcrlf & sunsorts(u(i ,0),sunlevel 1)
else
result = result &""& vbcrlf & sunsorts(u(i ,0),sunlevel 1)
end if
end if
next
sunsorts = result
end function
%>
用户登录
还没有账号?立即注册
用户注册
投稿取消
| 文章分类: |
|
还能输入300字
上传中....
用户17014497