欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

如何使用数组来显示下拉菜单?

程序员文章站 2022-05-03 15:58:40
sub dodropdown(arr(), strselname, onchange, strselected,...

sub dodropdown(arr(), strselname, onchange, strselected, strexclude)
dim i
      if strselected <> "" then
            swap arr, strselected
      end if
      response.write "<select name='" & strselname & "' size=1 onchange='" & onchange & "'>"
      for i = 0 to ubound(arr)
            if arr(i) <> "" and isnull(arr(i)) = false and arr(i) <> strexclude then
                  response.write "<option value=""" & arr(i) & """>" & arr(i) & "</option>"
            end if
      next
      response.write "</select>"
end sub

sub swap(arr(), strselected)
'
交换数组中的元素
dim storestring, i
      for i = 0 to ubound(arr)
            if arr(i) = strselected then
                  storestring = arr(i)
                  arr(i) = arr(0)
                  arr(0) = storestring
            end if
      next
end sub