如果要从数据库中读取数据,应该是服务器端脚本VBScript读取
<%
'定义函数
Function getSelectValue()
'设置数据库连接
Dim strSQL,Rs,Conn Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DSC=test"
strSQL = "select optionValue from test1 order by optionValue"
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.Open strSQL,Conn,1,1
'读取数据
Dim strReturnValue
strReturnValue = ""
Do While Not(Rs.Eof Or Rs.Bof)
strReturnValue = strReturnValue & "<option value='" & Rs(0) & "'>" & Rs(0) & "</option>"
Rs.MoveNext
Loop If ( strReturnValue = "" ) Then
strReturnValue = "没有可以选择的项"
End If '返回值
getSelectValue = strReturnValue
End Function
%><html>
<head>
<title>测试</title>
</head>
<body>
<select name="select1">
<%=getSelectValue()%>
</select>
</body>
</html>
<%
'定义函数
Function getSelectValue()
'设置数据库连接
Dim strSQL,Rs,Conn Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DSC=test"
strSQL = "select optionValue from test1 order by optionValue"
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.Open strSQL,Conn,1,1
'读取数据
Dim strReturnValue
strReturnValue = ""
Do While Not(Rs.Eof Or Rs.Bof)
strReturnValue = strReturnValue & "<option value='" & Rs(0) & "'>" & Rs(0) & "</option>"
Rs.MoveNext
Loop If ( strReturnValue = "" ) Then
strReturnValue = "没有可以选择的项"
End If '返回值
getSelectValue = strReturnValue
End Function
%><html>
<head>
<title>测试</title>
</head>
<body>
<select name="select1">
<%=getSelectValue()%>
</select>
</body>
</html>
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货