加兩個欄位,一個是父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