日期:2010-02-03 浏览次数:20779 次
加两个字段,一个是父ID,如果是顶层,父ID就为0,一个是是否有下级,0元1有,一个函数就可解决,在函数中间调用本函数,找出了父层,再找他是否有下级,如果有,再找父ID为本ID的栏目
'==================================================
'过程名:listecityclass
'作 用:显示系统分类
'参 数:id ------ 要匹配的系统ID
'==================================================
Sub listecityclass(id)
dim F_reco,F_total,F_n,F_classid,F_classname,F_classlayer
set F_reco=Server.CreateObject("ADODB.Recordset")
F_reco.Open "select classid,classname,classlayer from ws_ecityclass where classparent=0 and classlist=0 order by classorder Asc",conn,1,1
F_total=F_reco.recordcount
if F_total>0 then
for F_n=1 to F_total
format_i=1
F_classid=F_reco(0)
F_classname=F_reco(1)
F_classlayer=F_reco(2)
response.write "<option"
if F_classlayer=0 then response.write " value=" & F_classid
if id=F_classid then response.write " selected"
response.write ">" & F_classname & "</option>"
if F_classlayer=1 then call listecityclass_(id,F_classid) '调用另一个函数,在下面
F_reco.movenext
next
end if
F_reco.close : set F_reco=nothing
End Sub
Sub listecityclass_(id,iid)
dim F_reco,F_total,F_n,F_m,F_classid,F_classname,F_classlayer
set F_reco=Server.CreateObject("ADODB.Recordset")
F_reco.Open "select classid,classname,classlayer from ws_ecityclass where classparent="&iid&" and classlist=0 order by classorder Asc",conn,1,1
F_total=F_reco.recordcount
if F_total>0 then
for F_n=1 to F_total
F_classid=F_reco(0)
F_classname=F_reco(1)
F_classlayer=F_reco(2)
format_i=format_i+1
response.write "<option"
if F_classlayer=0 then response.write " value=" & F_classid
if id=F_classid then response.write " selected"
response.write ">"
for F_m=format_i to 2 step -1
response.write " "
if F_m=2 then
if F_n=F_total then response.write "└" else response.write "├"
end if
next
response.write F_classname & "</option>"
if F_classlayer=1 then call listecityclass_(id,F_classid) '调用本函数
F_reco.movenext
format_i=format_i-1
next
end if
F_reco.close : set F_reco=nothing
End Sub