![]() |
#2
ljc_zy2009-09-23 12:11
看我篇文章:
一个asp+javascript结合的二级联动的例子 <% dim rs dim sql dim count set rs=server.createobject("adodb.recordset") sql = "select * from Nclass order by Nclassid asc" rs.open sql,conn,1,1'打开分类 %><SCRIPT language="JavaScript"> var onecount; onecount=0; subcat = new Array();//用JS建一个数组 <% count = 0 do while not rs.eof '通过ASP循环来生成这个数组 %> subcat[<%=count%>] = new Array("<%= trim(rs("Nclass"))%>","<%= trim(rs("classid"))%>","<%= trim(rs("Nclassid"))%>");//得到SUBCAT[I]=new Array(NCLASS,CLASSID,NCLASSID)格式的数组 <% count = count + 1 rs.movenext loop rs.close %> onecount=<%=count%>; function changelocation(locationid) { document.myform.Nclassid.length = 0; //副SELECT的SELECT的个数为0 var locationid=locationid;//声明一下 var i; for (i=0;i < onecount; i++)//把数组顺次循环出来 { if (subcat[i][1] == locationid)//如果上面数组中有一个是现在的LOCATIONID,也就是主SELECT改变时,document.myform.classid.options[document.myform.classid.selectedIndex].value这个值,就执行下面的 { document.myform.Nclassid.options[document.myform.Nclassid.length] = new Option(subcat[i][0], subcat[i][2]);//生成副SELECT的OPTION,document.myform.Nclassid.length,有多少个符合的数组,长度就有多少,把数组值传给OPTIONS,当到哪个相同数组时,就生成第几个OPTION,并把数组值传给OPTION } } } </SCRIPT> 主select <SELECT name="classid" onChange="changelocation(document.myform.classid.options[document.myform.classid.selectedIndex].value)" size="1"> 本文来源于网络小筑 http://www. , 原文地址:http://www. |
请各位帮帮忙啊
我一个MDB文件,里面一张GZ表,表中有三个字段分别:时间/数量/地点
通过什么方法实行这样的效果:
在网页中添加两个列表框(select1和select2)
其中select1预先设定值为:时间/数量/地点
当我在select1中切换不同的选项时,则在select2动态列出对应select1中所选择的字段的值
如:当我在select1中选择"时间"这个字段时,则在select2中列出数据中库"时间"这个字段的所有记录
当我在select1中切换选择到"数量"这个字段时,则在select2中列出数据中库"数量"这个字段的所有记录
请大家一定帮忙啊,在线死等