ASP function code for all child class IDs recursively based on parent ID

Source: Internet
Author: User
Tags end

加两个字段,一个是父ID,如果是顶层,父ID就为0,一个是是否有下级,0元1有,一个函数就可解决,在函数中间调用本函数,找出了父层,再找他是否有下级,如果有,再找父ID为本ID的栏目

'==================================================
' Procedure name: Listecityclass
' Function: Display system classification
' Parameter: ID------the system ID to match
'==================================================
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 the 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) ' invokes another function, in the following
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 C Lassorder 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) ' calls this function
F_reco.movenext
Format_i=format_i-1
Next
End If
F_reco.close:set f_reco=nothing
End Sub



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.