asp高手请进!递规问题 请高手知道

WiseDragon 2006-06-27 08:59:01
category是个2维数组
category(0,i)是分类编号, category(1,i)分类名称, category(2,i)是上级分类编号
Sub SubCategory(parentId)
dim i
if count>0 then
for i=0 to count-1
if category(2,i)=parentId then
Response.Write("<option value='"& category(0,i) &"'>"& category(1,i)&"</option>")
call SubCategory(category(0,i))
end if
next
end if
End Sub

这个递規可以实现
A
a1
a1
a3
B
b1
b2
但就是子类在父类下没有缩进 我想实现
A
---a1
---a2
B
---b2
---b2
的效果

那位高手可以做出
...全文
108 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
indexroot 2006-06-28
  • 打赏
  • 举报
回复
Dim category(2,10)
count=11

category(0,0)=0
category(1,0)="ROOT"
category(2,0)=-1

category(0,1)=1
category(1,1)="A"
category(2,1)=0

category(0,2)=2
category(1,2)="B"
category(2,2)=0

category(0,3)=3
category(1,3)="A1"
category(2,3)=1

category(0,4)=4
category(1,4)="A2"
category(2,4)=1

category(0,5)=5
category(1,5)="A3"
category(2,5)=1

category(0,6)=6
category(1,6)="B1"
category(2,6)=2

category(0,7)=7
category(1,7)="B2"
category(2,7)=2

category(0,8)=8
category(1,8)="B3"
category(2,8)=2

category(0,9)=9
category(1,9)="B11"
category(2,9)=6

category(0,10)=9
category(1,10)="B12"
category(2,10)=6

Sub SubCategory(parentId,level)
dim i
if count>0 then
for i=0 to count-1
if category(2,i)=parentId then

Response.Write("<option value='"& category(0,i) &"'>" & showLine(level) & category(1,i)&"</option>")
call SubCategory(category(0,i),level+1)
end if
next

end if
End Sub

Function showLine(n)
for i=1 to n
s=s&"---"
next
showLine=s
End Function

Response.Write("<select>")
call SubCategory(-1,-1)
Response.Write("</select>")
WiseDragon 2006-06-28
  • 打赏
  • 举报
回复
谢谢上面的大哥 万分感谢 高手阿

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧