如数据库里有条记录字段名为‘序列号’‘名称’‘数量’,值分别为‘1’‘交换机’‘10’。
现有一个下拉框和两个文本框,要求下拉框里的值是字段‘序列号’下的值1,当选1的时候,文本框相对应的显示字段‘名称’和‘数量’的值,如何实现?
---------------------------------------------------------------
http://expert.csdn.net/Expert/topic/2970/2970355.xml?temp=.1002924
---------------------------------------------------------------
连动问题:
newbig:
CREATE TABLE [dbo].[newbig] (
[BigId] [nvarchar] (2) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[bigtypes] [nvarchar] (30) COLLATE Chinese_PRC_CI_AS NOT NULL
)
newmiddle
CREATE TABLE [dbo].[newmiddle] (
[middleid] [nvarchar] (3) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[middletypes] [nvarchar] (25) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[bigid] [nvarchar] (10) COLLATE Chinese_PRC_CI_AS NULL
)
newsmall
CREATE TABLE [dbo].[newSmall] (
[Smallid] [nvarchar] (5) COLLATE Chinese_PRC_CI_AS NOT NULL ,
[SmallTypes] [nvarchar] (25) COLLATE Chinese_PRC_CI_AS NULL ,
[middleid] [nvarchar] (10) COLLATE Chinese_PRC_CI_AS NULL
)
1<table border="0" cellpadding="0" cellspacing="0" width="498">
2<tr>
3<td> <!-- #include file="conn.asp"--> <script language="javascript">
4function cc(theform5) {
5if ((theform5.txt.value=="") &&(theform5.sheng.value=="")&&(theform5.bigtypes.value==""))
6{ alert("查询条件都不能为空。");
7theform5.txt.focus();
8return false;
9}
10return true;
11}
12</script> ```
13
14sql = "select shengid,cityid,sheng,city from newcity order by cityid"
15set obj = conn.execute(sql)
16
17``` <script language="JavaScript">
18var onecouant;
19onecouant=0;
20subcata = new Array();
count1 = 0
do while not obj.eof
1subcata[```
2=count1
3```] = new Array("```
4= trim(obj("City"))
5```","```
6= trim(obj("shengid"))
7```","```
8= trim(obj("cityid"))
9```");
count1 = count1 + 1
obj.movenext
loop
obj.close
set obj=nothing
1onecouant=```
2=count1
3```;
4
5function changelocation3(id)
6{
7document.f1.city.length = 0;
8
9var id=id;
10var i;
11document.f1.city.options[0] = new Option('----------请选择城市---------','');
12for (i=0;i < onecouant; i++)
13{
14if (subcata[i][1] == id)
15{
16document.f1.city.options[document.f1.city.length] = new Option(subcata[i][0], subcata[i][2]);
17}
18}
19
20}
21</script></td>
22</tr>
23</table>
1<form action="newEnterprise/AllSearch.asp" method="post" name="f1" onsubmit="return cc(f1)">
2<table align="center" bgcolor="#FFFFFF" border="0" cellpadding="0" cellspacing="0" width="400">
3<tr bgcolor="e6e6e6">
4<td align="center" height="35" width="101"><strong>选择省份</strong></td>
5<td height="35" width="349"><select name="sheng" onchange="changelocation3(document.f1.sheng.options[document.f1.sheng.selectedIndex].value)" size="1">
6<option selected="" value="">\----------请选择省份---------</option>
sql1 = "select shengid,sheng from newsheng order by Shengid"
set obj1 = conn.Execute (sql1)
do while not obj1.eof
1<option ```"="" shengid"))="" value="```
2=trim(obj1(">```
3=trim(obj1("Sheng"))
4```</option>
obj1.movenext
loop
obj1.close
set obj1 = nothing
1</select></td>
2</tr>
3<tr bgcolor="e6e6e6">
4<td align="center" height="35" width="101"><strong>地区(市)</strong></td>
5<td height="35" width="349"><select name="city" size="1">
6<option selected="" value="">\------请选择城市------</option>
7</select></td>
8</tr>
9<script language="JavaScript">
10changelocation3(document.f1.sheng.options[document.f1.sheng.selectedIndex].value);
11</script>
12<tr bgcolor="e6e6e6">
13<td align="center" height="33" width="101"><strong>行业大类</strong></td>
14<td height="33" width="349">```
15
16sql = "select bigid,middleid,middletypes from newmiddle order by middleid"
17set rs = conn.execute(sql)
18
19``` <script language="JavaScript">
20var onecount;
21onecount=0;
22subcat = new Array();
count = 0
do while not rs.eof
1subcat[```
2=count
3```] = new Array("```
4= trim(rs("middletypes"))
5```","```
6= trim(rs("bigid"))
7```","```
8= trim(rs("middleid"))
9```");
count = count + 1
rs.movenext
loop
rs.close
set rs=nothing
1onecount=```
2=count
3```;
4
5function changelocation(locationid)
6{
7document.f1.middletypes.length = 0;
8
9var locationid=locationid;
10var i;
11document.f1.middletypes.options[0] = new Option('--中类行业--','');
12for (i=0;i < onecount; i++)
13{
14if (subcat[i][1] == locationid)
15{
16document.f1.middletypes.options[document.f1.middletypes.length] = new Option(subcat[i][0], subcat[i][2]);
17}
18}
19
20}
21</script> ```
22sql2 = "select smalltypes,middleid,smallid from newsmall order by smallid"
23set rs2 = conn.execute(sql2)
24
25``` <script language="JavaScript">
26var onecount2;
27onecount2=0;
28subcat2 = new Array();
count2 = 0
do while not rs2.eof
1subcat2[```
2=count2
3```] = new Array("```
4= trim(rs2("smalltypes"))
5```","```
6= trim(rs2("middleid"))
7```","```
8= trim(rs2("smallid"))
9```");
count2 = count2 + 1
rs2.movenext
loop
rs2.close
set rs2=nothing
1onecount2=```
2=count2
3```;
4
5function changelocation2(smalltypesid)
6{
7document.f1.smalltypes.length = 0;
8
9var smalltypesid=smalltypesid;
10var j;
11document.f1.smalltypes.options[0] = new Option('--小类行业--','');
12for (j=0;j < onecount2; j++)
13{
14if (subcat2[j][1] == smalltypesid)
15{
16document.f1.smalltypes.options[document.f1.smalltypes.length] = new Option(subcat2[j][0], subcat2[j][2]);
17}
18}
19
20}
21
22</script> <select name="bigtypes" onchange="changelocation(document.f1.bigtypes.options[document.f1.bigtypes.selectedIndex].value)" size="1">
23<option selected="" value="">\--------选择大类行业---------</option>
sql1 = "select bigid,bigtypes from newbig order by bigid"
set rs1 = conn.Execute (sql1)
do while not rs1.eof
1<option ```"="" bigid"))="" value="```
2=trim(rs1(">```
3=trim(rs1("bigtypes"))
4```</option>
rs1.movenext
loop
rs1.close
set rs1 = nothing
conn.close
set conn=nothing
1</select></td>
2</tr>
3<tr bgcolor="e6e6e6">
4<td align="center" height="35" width="101"><strong>行业中类</strong></td>
5<td height="35" width="349"><select name="middletypes" onchange="changelocation2(document.f1.middletypes.options[document.f1.middletypes.selectedIndex].value)">
6<option selected="" value="">\--------选择中类行业---------</option>
7</select></td>
8</tr>
9<tr bgcolor="e6e6e6">
10<td align="center" height="35" width="101"><strong>行业小类</strong></td>
11<td height="35" width="349"><select name="smalltypes" size="1">
12<option selected="" value="">\--------选择小类行业---------</option>
13</select></td>
14</tr>
15<tr bgcolor="e6e6e6">
16<td height="35" width="101"> </td>
17<td height="35" width="349"><input name="Submit3" type="submit" value=" 搜索 "/>
18<input name="Submit5" type="reset" value=" 重写 "/></td>
19</tr>
20</table>
21</form>