逗号将String分隔成经典asp中的下拉列表

时间:2012-09-27 08:49:28

标签: asp-classic

我有一个逗号分隔的字符串 比如12345,67890,3453,124556,56778 我想在下拉列表中显示这些项目

我正在使用经典的asp页面。

请帮我解决这个问题

1 个答案:

答案 0 :(得分:5)

尝试一下:

<%
' put your string into a variable.
Dim myString : myString = "12345,67890,3453,124556,56778"

' split your variable up into a array
Dim splitmystring : splitmystring = split(myString,",")

' create a dropdown box
Response.write  "<select value=""dropdown"">"
Response.write  "<option selected>choose a option</option>"

' Loop through your array
For Each item In splitmystring
    response.write "<option value='"& item &"'>"& item & "</option>"
Next

'close your dropdown box
response.write "</select>"
%>