'author:chjpeng
'email:
[email protected]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 "<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
可以从数据库中读出数据,形成逗开分隔的字符串,来动态生成select的<option>
function getArrString(table,fld,cond,sortfld)
'获取一个指定表中指定字段指字条件的数据,返回一个以逗号分隔的字符串
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 while 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
(出处:http://www.sheup.com)