如何动态更新ASP中下拉框的内容
2017-12-29 · 知道合伙人数码行家
huanglenzhi
知道合伙人数码行家
向TA提问 私信TA
知道合伙人数码行家
采纳数:117538
获赞数:517181
长期从事计算机组装,维护,网络组建及管理。对计算机硬件、操作系统安装、典型网络设备具有详细认知。
向TA提问 私信TA
关注
展开全部
'数据库结构
'类别1表名称:a 字段:ID,Name 说明:ID为主键是类别1的ID值,Name为类别1的名称
'类别2表名称:aa 字段:ID,aID,Name 说明:ID为主键是类别2的ID值,aID为所属类别1的ID值,Name为类别2的名称
'类别3表名称:aaa 字段:ID,aID,aaID,Name 说明:ID为主键是类别3的ID值,aID为所属类别1的ID值,aaID为所属类别2的ID值,Name为类别3的名称
=====test1.asp 接收到的都是类别的ID值====
< %
response.write" 1:" & Request.form(" s1" )& " < BR> "
response.write" 2:" & Request.form(" s2" )& " < BR> "
response.write" 3:" & Request.form(" s3" )& " < BR> "
%>
=========================================================
< !-- 三级联动菜单 开始 -->
< script language=" JavaScript" >
< !--
< %
'二级数据保存到数组
Dim count2,rsClass2,sqlClass2
set rsClass2=server.createobject(" adodb.recordset" )
sqlClass2=" select * from aa"
rsClass2.open sqlClass2,conn,1,1
%>
var subval2 = new Array();
//数组结构:一级根值,二级根值,二级显示值
< %
count2 = 0
do while not rsClass2.eof
%>
subval2[< %=count2%> ] = new Array('< %=rsClass2(" aID" )%> ','< %=rsClass2(" ID" )%> ','< %=rsClass2(" Name" )%> ')
< %
count2 = count2 + 1
rsClass2.movenext
loop
rsClass2.close
%>
< %
'三级数据保存到数组
Dim count3,rsClass3,sqlClass3
set rsClass3=server.createobject(" adodb.recordset" )
sqlClass3=" select * from aaa"
rsClass3.open sqlClass3,conn,1,1
%>
var subval3 = new Array();
//数组结构:二级根值,三级根值,三级显示值
< %
count3 = 0
do while not rsClass3.eof
%>
subval3[< %=count3%> ] = new Array('< %=rsClass3(" aaID" )%> ','< %=rsClass3(" ID" )%> ','< %=rsClass3(" Name" )%> ')
< %
count3 = count3 + 1
rsClass3.movenext
loop
rsClass3.close
%>
function changeselect1(locationid)
{
document.form1.s2.length = 0;
document.form1.s2.options[0] = new Option('==请选择类别==','');
document.form1.s3.length = 0;
document.form1.s3.options[0] = new Option('==请选择专题==','');
for (i=0; i< subval2.length; i++)
{
if (subval2[i][0] == locationid)
{ document.form1.s2.options[document.form1.s2.length] = new Option(subval2[i][2],subval2[i][1]); }
}
}
function changeselect2(locationid)
{
document.form1.s3.length = 0;
document.form1.s3.options[0] = new Option('==请选择专题==','');
for (i=0; i< subval3.length; i++)
{
if (subval3[i][0] == locationid)
{ document.form1.s3.options[document.form1.s3.length] = new Option(subval3[i][2],subval3[i][1]); }
}
}
//-->
< /script>
< form name=" form1" method=" post" action=" test1.asp" >
三级联动:
< %
Dim count1,rsClass1,sqlClass1
set rsClass1=server.createobject(" adodb.recordset" )
sqlClass1=" select * from a"
rsClass1.open sqlClass1,conn,1,1
%>
< select name=" s1" onChange=" changeselect1(this.value)" >
< option> ==请选择频道==< /option>
< %
count1 = 0
do while not rsClass1.eof
response.write" < option value=" & rsClass1(" ID" )& " > " & rsClass1(" Name" )& " < /option> "
count1 = count1 + 1
rsClass1.movenext
loop
rsClass1.close
%>
< /select>
< select name=" s2" onChange=" changeselect2(this.value)" >
< option> ==请选择类别==< /option>
< /select>
< select name=" s3" >
< option> ==请选择专题==< /option>
< /select>
< input type=" submit" name=" Submit" value=" 提交" > < /form>
< !-- 三级联动菜单 结束 -->
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询