A generic option output function is written for select

Source: Internet
Author: User
Tags split trim
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



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.