ASP: Tree Select menu

Source: Internet
Author: User

Call Process

<%
Dim RSS, u
Set RSS = server. Createobject ("ADODB. recordset ")
RSS. Open "select ID, parentid, sortname from [sorts] order by parentid", Conn, 1, 1
Response. Write "<select onchange =" "mm_jumpmenu ('false', this, 0)"> "& getlisttree &" <SELECT>"
RSS. Close
%>

The function that generates the menu. 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 ("parentid ")
U (I-1, 2) = RSS ("sortname ")
RSS. movenext
Next
'Rss. movefirst
For I = 0 to ubound (u)-1
If int (U (I, 1) = 0 then
Result = Result & "<option value = '? Sortid = "& U (I, 0) &" & parentid = "& parentid &" '> random "& U (I, 2) & "</option>" & 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)
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 & "<option" & selected & "value = '? Sortid = "& U (I, 0) &" & parentid = "& parentid &" '> "& sp &" random "& U (I, 2) & "</option>" & vbcrlf & sunsorts (U (I, 0), sunlevel + 1)
Else
Result = Result & "<option" & selected & "value = '? Sortid = "& U (I, 0) &" & parentid = "& parentid &" '> "& sp &" random "& U (I, 2) & "</option>" & vbcrlf & sunsorts (U (I, 0), sunlevel + 1)
End if
End if
Next
Sunsorts = Result
End Function

 

Effect

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.