function writeSlt(arrstr,arrstrValue,selectedstr)
'arrstr The value to be displayed in option, arrstrValue The actual value of option, selectedstr The default value to be selected
'Split a string into an array, output the selected option, and select selectedstr arrstr&arrstrValue to have the same length
arr=split(arrstr,",")
arrValue=split(arrstrValue,",")
j=0
do while j<=ubound(arr)
if trim(arrValue(j))=trim(selectedstr) then
response.write "<option value='" & arrValue(j) & "' selected>" & arr(j) & "</option>"
else
response.write "<option value='" & arrValue(j) & "'>" & arr(j) & "</option>"
end if
j=j+1
loop
end function
Data can be read from the database to form a comma-delimited string to dynamically generate select's <option>
function getArrString(table,fld,cond,sortfld)
'Get the data of the specified field in the specified table and return a comma-separated string
set rs=server.createobject("adodb.recordset")
sql="select " & fld & " from " & table
if len(cond)>0 then
sql=sql & " where " & cond
end if
if len(sortfld)>0 then
sql=sql & " order by " & sortfld
end if
rs.Open sql,conn,1,1
if not (rs.bof or rs.EOF) then
do while not rs.EOF
getArrString=getArrString & trim(rs(fld)) & ","
rs.MoveNext
loop
end if
getArrString=left(getArrString,len(getArrString)-1)
rs.Close
set rs=nothing
end function