asp下二级下拉框联动问题???指针不向下移动??

homel 2008-07-05 09:15:48
各位:请大家给看看:
数据表结构:
onhand_id subinventory_code inventory_item_id
1 4 787
2 4 789
3 5 890
4 5 785

现在想实现的功能是:当我选择第一个下拉菜单中的值4时:第二个下拉菜单中显示:787和789两项
但是现在做的指针根本不往下移动,请高手给解决一下,谢谢(急啊....)
以下是代码:
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp" -->
<% dim count
set rs=server.CreateObject("adodb.recordset")
rs.open"select * from mtl_onhand_quantities ",conn,1,1
%>

<SCRIPT language="javascript">
var onecount;
onecount=0;
subcat = new Array();
<%
count = 0
do while not rs.eof
%>
subcat[<%=count%>] = new Array("<%=rs("subinventory_code")%>","<%=rs("inventory_item_id")%>","<%=rs("onhand_id")%>");
<%
count = count + 1
rs.movenext
loop
rs.close
set rs=nothing
%>
onecount=<%=count%>;
function changelocation(locationid)
{
document.myform.id.length = 0;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
if (subcat[i][1] == locationid)
document.myform.id.options[document.myform.id.length] = new Option(subcat[i][0], subcat[i][2]);
}
</SCRIPT>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
</head>

<body>
<%
set rs=server.CreateObject("adodb.recordset")
'rs.open"select eq_id,eq_number,eq_name from equipment_detail where company_code='"&session("company")&"'and workstation_code in (select user_station_code from tbl_user_level where user_id='"&session("user_id")&"'and status=1)",conn,1,1
rs.open"select distinct subinventory_code from mtl_onhand_quantities ",conn,1,1
if not rs.eof then
%>

<select name="system_id" class="txtBoxStyle2" id="system" onChange="changelocation(document.myform.system_id.options[document.myform.system_id.selectedIndex].value)">
<option selected value="<%=rs("subinventory_code")%>"><%=rs("subinventory_code")%></option>
<% dim seleq
seleq=rs("subinventory_code")
rs.movenext
do while not rs.eof
%>
<option value="<%=rs("subinventory_code")%>"><%=rs("subinventory_code")%></option>
<%
rs.movenext
loop
rs.close
set rs=nothing
%>
</select>
<select name="id" id="id">
<%
set rs2=server.CreateObject("adodb.recordset")
sql="select * from mtl_onhand_quantities where subinventory_code="&seleq
response.Write sql
rs2.open sql,conn,1,3
if not(rs2.eof and rs2.bof) then
%>
<option selected value="<%=trim(rs2("onhand_id"))%>"><%=trim(rs2("inventory_item_id"))%></option>
<%rs2.movenext
do while not rs2.eof%>
<option value="<%=trim(rs2("onhand_id"))%>"><%=trim(rs2("inventory_item_id"))%></option>
<% rs2.movenext
loop
end if
rs2.close
set rs2=nothing
%>
</select> <%end if%>
</body>
</html>
...全文
116 21 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
21 条回复
切换为时间正序
请发表友善的回复…
发表回复
lengcj 2011-03-17
  • 打赏
  • 举报
回复
我也是这问题啊
  • 打赏
  • 举报
回复
给你一个js版二级下拉菜单,你可以参考一下
http://blog.csdn.net/sandyxxx/archive/2008/04/28/2337281.aspx
jhwcd 2008-07-05
  • 打赏
  • 举报
回复
把<option selected value="<%=trim(rs2("onhand_id"))%>"><%=trim(rs2("inventory_item_id"))%></option>
<%rs2.movenext
do while not rs2.eof%>
<option value="<%=trim(rs2("onhand_id"))%>"><%=trim(rs2("inventory_item_id"))%></option>
<% rs2.movenext
loop
改成下面这样试试。
<%
do while not rs2.eof
%>
<option value="<%=trim(rs2("onhand_id"))%>"><%=trim(rs2("inventory_item_id"))%></option>
<% rs2.movenext
loop
%>
homel 2008-07-05
  • 打赏
  • 举报
回复
我觉得我的算法没有问题啊
只不过是实现起来有问题啊
也有可能是自己现在的思路有问题,
所以我才来问大家,集思广益的...
不过还是很感谢你...
  • 打赏
  • 举报
回复
自己整理下思路和程序结构
  • 打赏
  • 举报
回复
[Quote=引用 13 楼 homel 的回复:]
按你说的连参数都没有传递,怎么可能呢?
第二个下拉菜单中根本就没有值啊?
我测试了,只显示“请指定小类"..
[/Quote]

你的程序有问题
homel 2008-07-05
  • 打赏
  • 举报
回复
回复楼上的,没有.3ks
ymhdlh 2008-07-05
  • 打赏
  • 举报
回复
我觉得你是不是把2个下拉列表都勾上刷新了?第2个下拉列表不要刷新就能选择了。不知道你要解决的是不是这个问题。因为现在这台电脑上没安装软件,无法调试。
homel 2008-07-05
  • 打赏
  • 举报
回复
按你说的连参数都没有传递,怎么可能呢?
第二个下拉菜单中根本就没有值啊?
我测试了,只显示“请指定小类"..
  • 打赏
  • 举报
回复
你自己的程序里面乱的肯,你先把思路和程序重新整理下吧
  • 打赏
  • 举报
回复
<select name="id" id="id">
<%
set rs2=server.CreateObject("adodb.recordset")
sql="select * from mtl_onhand_quantities where subinventory_code="&seleq
response.Write sql
rs2.open sql,conn,1,3
if not(rs2.eof and rs2.bof) then
%>
<option selected value="<%=trim(rs2("onhand_id"))%>"><%=trim(rs2("inventory_item_id"))%></option>
<%rs2.movenext
do while not rs2.eof%>
<option value="<%=trim(rs2("onhand_id"))%>"><%=trim(rs2("inventory_item_id"))%></option>
<% rs2.movenext
loop
end if
rs2.close
set rs2=nothing
%>
</select> <%end if%>

你这部分做纯属多余

只需要
<select name="id" id="id">
<option selected value="">请指定小类</option>
</select>
这样简单的就可以了
homel 2008-07-05
  • 打赏
  • 举报
回复
回复楼上的之前我也是这样写的
但是还是如我上面提示的错误,请帮我看看
真的没有什么思路了..
  • 打赏
  • 举报
回复
你这个代码本身就有问题

subcat[<%=count%>] = new Array("<%=rs("inventory_item_id")%>","<%=rs("subinventory_code")%>","<%=rs("onhand_id")%>");
你改成这样应该是没有问题了
xiaominjun 2008-07-05
  • 打赏
  • 举报
回复
<form method="post" action="AddProduct.asp" name="doublecombo" onSubmit="return CheckForm()">
<script>
function ToClass(ID,ClsID,Next)
{
Next.length =0;
if(ID==2)
str=document.doublecombo.hid2.value;
else if(ID==3)
str=document.doublecombo.hid3.value;
else if(ID==4)
str=document.doublecombo.hid4.value;

Next.options[Next.length] = new Option("-请选择-",0);

subcat=str.split("|");

for(i=0;i<subcat.length-1;i++)
{
pp=subcat[i].split("/")
if(parseInt(pp[0],10)==parseInt(ClsID,10))
{
tt=pp[1].split(",")
Next.options[Next.length] = new Option(tt[1],tt[0]);
}
}
}
</script>
<span class="banma2">
<select size="1" name="AcceptNetbarKey1" class="face" style="width:145" onchange="ToClass(2,document.doublecombo.AcceptNetbarKey1.options[document.doublecombo.AcceptNetbarKey1.selectedIndex].value,document.doublecombo.AcceptMemberKey1)">
<option value="36" selected="selected">-请选择-</option>
<option value="28">半导体照明光源</option>
<option value="29">半导体照明灯具</option>
<option value="30">城市亮化与泛光照明系统</option>
<option value="31">显示屏系统</option>
</select>
</span><span class="banma2">
<select name="AcceptMemberKey1" style="width:145" class="face" onclick="ToClass(3,document.doublecombo.AcceptMemberKey1.options[document.doublecombo.AcceptMemberKey1.selectedIndex].value,document.doublecombo.ff1)">
<option value="0">-请选择-</option>
</select>
</span><span class="banma2">
<select id="ff" name="ff1" style="width:145" class="face" onchange="ToClass(4,document.doublecombo.ff1.options[document.doublecombo.ff1.selectedIndex].value,document.doublecombo.ff2)">
<option value="0">-请选择-</option>
</select>

<input type="hidden" name="hid2" value="28/96,大功率LED灯条|28/95,大功率LED射灯|28/94,大功率LED灯板|31/40,室内|30/38,智能遥控泛光装饰照明系统与亮化工程|29/35,LED台灯|28/32,大功率LED|31/41,室外|30/39,彩显幕墙系统与工程|29/36,LED日光灯|28/33,LED背光模组|29/37,LED路灯|28/34,管状灯|">
<input type="hidden" name="hid3" value="34/98,W系列管状灯|35/58,至尊系列|35/59,博士系列|35/60,Q宝系列|">
</form>



接分。 谢谢
homel 2008-07-05
  • 打赏
  • 举报
回复
回复上面的?
我选择的4指得是subinventory_code
subinventory_code 为4的值对应的inventory_item_id 确实为787和789啊?没有什么问题啊
我是调用的同一种table啊?
这样的sql
select * form table where subinventory_code=4
应该没有什么问题啊???
  • 打赏
  • 举报
回复
看你的数据库表结构和你的程序,你选择4的时候,怎么会出现787和789呢?
  • 打赏
  • 举报
回复
还有你使用什么关联?
  • 打赏
  • 举报
回复
你调用的是一个表中的?
homel 2008-07-05
  • 打赏
  • 举报
回复
回复ls的
就是选择的时候,第一个列表框中的值:不管选择的是哪一个subinventory_code,第二个下拉列表中只显示第一个subinvnetory_code中的值啊!
  • 打赏
  • 举报
回复
不往下走是什么意思?
原书附带光盘文件第2章 02/ 基于Ajax的留言板示例第3章 03/3.1.3.html JavaScript在Ajax中的作用范例 03/3.4.6.html 加入注释,实现九九乘法表 03/3.4.11.html 使用逻辑表达式范例第4章 04/4.1.2.html 使用if…else…处理条件不成立的情形范例 04/4.1.4.html 使用switch语句进行多重条件判断范例 04/4.1.6.html 使用do…while循环范例 04/4.1.9.html continue语句:停止当前循环进入下一次循环 04/4.2.3.html 给函数传递参数范例第5章 05/5.2.2.html 从Date对象中提取信息范例 05/5.3.2.html 使用随机函数Math.randon()范例 05/5.4.4.html 使用数组的length属性范例 05/5.6.4.html 文档操作初步范例:document对象 05/5.10.2.html 使用复选框范例 05/5.11.12.html 下拉框实例:二级联动的下拉列表菜单第6章 06/6.1.3.html 使用方括号([])引用对象的属性和方法范例 06/6.1.5.html 使用大括号({})语法创建无类型对象范例 06/6.1.6.html prototype原型对象范例 06/6.2.6.html 函数的apply、call方法和length属性范例 06/6.2.7.html 深入认识JavaScript中的this指针范例 06/6.3.2.html 使用prototype对象定义类成员范例 06/6.4.2.html 实现类的私有成员范例 06/6.6.1.html 利用共享prototype实现继承范例 06/6.6.2.html 利用反射机制和prototype实现继承范例 06/6.6.3.html prototype-1.3.1框架中的类继承实现机制范例 06/6.7.2.html 在JavaScript实现抽象类范例 06/6.8.3.html 给事件处理程序传递参数范例 06/6.8.4.html 使自定义事件支持多绑定范例 06/6.9/ 实例:使用面向对象思想处理cookie第7章 07/7.2.3.html 获取cookie的值范例 07/7.2.4.html 给cookie设置终止日期范例 07/7.2.5.html 删除cookie范例 07/7.2.8.html 综合示例:构造通用的cookie处理函数 07/7.4.2.html 使用定时器实现JavaScript的延期执行或重复执行范例 07/7.4.3.html 给定时器调用传递参数范例 07/7.5.3.html 使用throw语句抛出异常范例第8章 08/8.2.7.html 使用responseText获得返回的文本范例 08/8.2.8.html 使用responseXML属性获取范例 08/8.2.9.html 使用abort方法取消一个请求范例 08/8.3.2.html 使用post方法向服务器提交数据范例 08/8.3.3.html 实现服务器相关的二级联动菜单范例 08/a.html 用于ajax获取文件的示例 08/checkUserName.asp 检测用户名的代码文件第9章 09/9.3.1.html 直接引用结点范例 09/9.5.1.html 表格操作范例 09/9.5.5.html 添加单元格范例 09/9.5.8.html 删除行和单元格范例 09/9.5.9.html 交换两行的位置范例第10章 10/10.1.3.html CSS在Ajax开发中的作用 10/10.2.4.html 使用id选择器范例 10/1

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧