select| function |select| function ' Author:chjpeng
' Email:chjpeng@163.com
function Writeslt (ARRSTR,ARRSTRVALUE,SELECTEDSTR)
' Arrstr to display the value in option, arrstrvalue option's actual value, selectedstr the default value to select
' Divide a string into arrays, output select option, and select Selectedstr arrstr&arrstrvalue length to match
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
You can read the data from the database, form a string that is funny and separate, to dynamically generate a select <option>
function getarrstring (TABLE,FLD,COND,SORTFLD)
' Gets a comma-delimited string of data that specifies the word condition of the specified field in the table.
Set Rsdq=server.createobject ("Adodb.recordset")
Sqldq= "Select" & fld & "from" & Table
If Len (cond) >0 Then
SQLDQ=SQLDQ & "where" & Cond
End If
If Len (sortfld) >0 Then
SQLDQ=SQLDQ & "ORDER BY" & SORTFLD
End If
RSDQ. Open sqldq,conn,1,1
If not (Rsdq.bof or RSDQ.) EOF) Then
Do as not RSDQ. Eof
Getarrstring=getarrstring & Trim (RSDQ (FLD)) & ","
RSDQ. MoveNext
Loop
End If
Getarrstring=left (Getarrstring,len (getarrstring)-1)
RSDQ. Close
Set rsdq=nothing
End Function