两个下拉框的数据是从两个不同的表里面读取出来,之间存在一定的依赖关系,要求对应联动!且在本地实现,举个例子说,
一个下拉框有数据 1 另外一个是 2
value 显示内容 value 显示内容
01 mm 001 xx (01)
02 cc 002 xxx (02)
03 44 003 sdfa (03)
而实际上2里面还有个与1相关的字段如上括号所示!请高手帮帮忙啊 5555
...全文
1517打赏收藏
关于下拉框联动的问题,急在线等!
两个下拉框的数据是从两个不同的表里面读取出来,之间存在一定的依赖关系,要求对应联动!且在本地实现,举个例子说, 一个下拉框有数据 1 另外一个是 2 value 显示内容 value 显示内容 01 mm 001 xx (01) 02 cc 002 xxx (02) 03 44 003 sdfa (03) 而实际上2里面还有个与1相关的字段如上括号所示!请高手帮帮忙啊 5555
你还是研究一下这个吧
<%
dim conn,constr
constr="driver={microsoft access driver (*.mdb)};uid=admin;pwd=数据库密码;dbq="& server.mappath("class.mdb")
set conn=server.createobject("adodb.connection")
conn.open constr
set rs=server.createobject("adodb.recordset")
rs.open "select * from school order by anclassid",conn,1,1%>
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
<%
count = 0
do while not rs.eof
%>
subcat[<%=count%>] = new Array("<%= trim(rs("anclassid"))%>","<%= rs("anclass")%>","<%= rs("nclass")%>");
<%
count = count + 1
rs.movenext
loop
rs.close
%>
onecount=<%=count%>;
function changelocation(locationid)
{
document.form.Nclassid.length = 0;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][0] == locationid)
{
document.form.Nclassid.options[document.form.Nclassid.length] = new Option(subcat[i][2], subcat[i][2]);
}
}
}
</script>
<%
set rs=server.createobject("adodb.recordset")
rs.open "select distinct anclassid,anclass from school order by anclassid",conn,1,1
if rs.eof and rs.bof then
response.write "请先添加栏目。"
response.end
else
%>
<form name="form">
<select name="anclassid" size="1" id="class" onChange="changelocation(document.form.anclassid.value)">
<option selected value="<%=rs("anclassid")%>"><%=trim(rs("anclass"))%></option>
<% dim selclass
selclass=rs("anclassid")
rs.movenext
do while not rs.eof
%>
<option value="<%=rs("anclassid")%>"><%=trim(rs("anclass"))%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select>
<select name="Nclassid">
<%rs.open "select * from school where anclassid="&selclass ,conn,1,1
if not(rs.eof and rs.bof) then
%>
<option selected value="<%=rs("nclass")%>"><%=rs("nclass")%></option>
<% rs.movenext
do while not rs.eof%>
<option value="<%=rs("nclass")%>"><%=rs("nclass")%></option>
<% rs.movenext
loop
end if
rs.close
set rs = nothing
%>
</select>