从数据库中动态选取下拉列表的方法
有一页填表的页面,其中有几个下拉表单是通过一个表的某个字段动态
生成,比如省下面的城市名,希望选择某一个省即可自动在另一下拉表
单内生成城市名,.....然后提交给处理加入到另外一个表内。
<form name=f1 method="post">
<%
opendb objconn, "xxxx"
set rsclass = objconn.execute("select * from class order by fldclass")
if rsclass.eof then
response.write "没有记录。<br>"
else
response.write "<select name=""class"" style=""font-size: 9pt"" size=10" & _
" onchange=""classselected(this);"" >"
sjavascript = "function classselected(elem){" &_
vbcrlf & _
"for (var i = document.f1.sort.options.length; i >= 0; i--){" & vbcrlf & _
"document.f1.sort.options[i] = null;" & _
vbcrlf
do until rsclass.eof
if slastclass <> rsclass("fldclass") then
slastclass = rsclass("fldclass")
response.write "<option value=" & rsclass("fldid") & ">" & slastclass & "</option>"
sjavascript = sjavascript & "}" & vbcrlf & _
"if (elem.options[elem.selectedindex].value==" & _
rsclass("fldid") & "){" & vbcrlf
end if
sjavascript = sjavascript & _
"document.f1.sort.options[document." & _
"f1.sort.options.length] = new option(" & _
rsclass("fldsort") & "," & rsclass("fldid") & ");" & _
vbcrlf
rsclass.movenext
loop
response.write "</select>"
response.write "<select name=""sort"" style=""font-size: 9pt"" size=10>"
response.write "<option>[请选择]</option>"
response.write "</select>"
sjavascript = sjavascript & vbcrlf & "}" & vbcrlf & "}" & vbcrlf
上一篇: 如何通过站内运营和推广打造爆款?
下一篇: 大家知道枸杞寒性吗