function writeSlt(arrstr,arrstrValue,selectedstr)
'arrstr 要显示在option里面的值,arrstrValue option的实际值,selectedstr要选中的默认值
'将一个字串分割为数组,输出select的option,并选中selectedstr arrstr&arrstrValue长度要一致
arr=split(arrstr,",")
arrValue=split(arrstrValue,",")
j=0
do while j<=ubound(arr)
if trim(arrValue(j))=trim(selectedstr) then
response.write "
1<option selected="" value='" & arrValue(j) & "'>" & arr(j) & "</option>
"
else
response.write "
1<option value='" & arrValue(j) & "'>" & arr(j) & "</option>
"
end if
j=j+1
loop
end function
可以从数据库中读出数据,形成逗开分隔的字符串,来动态生成select的
1<option>
2
3function getArrString(table,fld,cond,sortfld)
4'获取一个指定表中指定字段指字条件的数据,返回一个以逗号分隔的字符串
5set rs=server.createobject("adodb.recordset")
6sql="select " & fld & " from " & table
7if len(cond)>0 then
8sql=sql & " where " & cond
9end if
10if len(sortfld)>0 then
11sql=sql & " order by " & sortfld
12end if
13rs.Open sql,conn,1,1
14if not (rs.bof or rs.EOF) then
15do while not rs.EOF
16getArrString=getArrString & trim(rs(fld)) & ","
17rs.MoveNext
18loop
19end if
20getArrString=left(getArrString,len(getArrString)-1)
21rs.Close
22set rs=nothing
23end function</option>