欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

如何制作关联的下拉菜单?

程序员文章站 2022-05-03 15:32:10
<%opendb objconn, "...

<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--){" 

"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 & "}" 

"if (elem.options[elem.selectedindex].value=="

rsclass("fldid") & "){"

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  & "}"  & "}"

 

response.write "<scr" & "ipt language=""javascript"">"

response.write sjavascript  & "</scr" & "ipt>"

 

end if

rsclass.close

set rsclass = nothing

%>

</form>