注册 登录
编程论坛 ASP技术论坛

请教下拉列表级联问题(已重新编辑,图可见,附源码)。

wwm123456789 发布于 2012-03-03 18:25, 699 次点击
数据库结构及数据如图
只有本站会员才能查看附件,请 登录

网页界面如图
只有本站会员才能查看附件,请 登录
,希望实现的功能是,当我选择的
材料名称为“打印纸”时,
型号品牌中选项只有"16k"
单位中选项只有“包”

请指教,谢谢!
程序代码:
<!--#include file="aspcon.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>材料管理系统</title>
</head>
<body bgcolor="#CCFFFF" link="#0000FF" vlink="#0000FF" alink="#FF0000">
<center>
<table width="800" border="1">
  <tr>
    <td><div align="center">
      <h1>耗材领用登记</h1></p>
      <form name="form1" method="post" action="aa.asp">
        <table width="75%" border="1">
          <tr>
            <td><font size="+1">材料名称</font>:</td>
            <td><font size="+1">
              <select name="name" size="1" id="name" style= "background-color:#eeeeee;width:150px;font-size:12px;"  onkeydown="catch_keydown(this);" onkeypress="catch_press(this);">
                <option></option>
                <%
sql
="select distinct(name) from rkb order by name" '去掉重复值
set rs=conn.execute(sql)
do while rs.eof=false
%>
                <option><%=rs("name")%></option>
                <%
rs.movenext
loop
%>
              </select>
            </font></td>
          </tr>
          <tr>
            <td width="25%"><font size="+1">型号品牌:</font></td>
            <td width="75%"><font size="+1">
              <select name="xh" size="1" id="xh" style= "background-color:#eeeeee;width:150px;font-size:12px;" onkeydown="catch_keydown(this);" onkeypress="catch_press(this);">
                <option></option>
                <%
sql
="select distinct(xh) from rkb order by xh" '去掉重复值
set rs=conn.execute(sql)
do while rs.eof=false
%>
                <option><%=rs("xh")%></option>
                <%
rs.movenext
loop
%>
              </select>
            </font></td>
          </tr>
          <tr>
            <td><font size="+1">单位</font>:</td>
            <td><font size="+1">
              <select name="dw" size="1" id="dw"  style= "background-color:#eeeeee;width:150px;font-size:12px;" onkeydown="catch_keydown(this);" onkeypress="catch_press(this);">
                <option></option>
                <%
sql
="select distinct(dw) from rkb order by dw" '去掉重复值
set rs=conn.execute(sql)
do while rs.eof=false
%>
                <option><%=rs("dw")%></option>
                <%
rs.movenext
loop
%>
              </select>
            </font></td>
          </tr>
        </table>
            <table width="75%" border="1">
  <td width="25%"><font size="+1">数量:</font></td>
      <td width="75%"><font size="+1">
        <select name="sl" size="1" id="sl"  style= "background-color:#eeeeee;width:150px;font-size:12px;">
          <option>1</option>
        </select>
      </font></td>
  </tr>
  <tr>
    <td><font size="+1">用途:</font>:</td>
    <td><font size="+1">
      <select name="yt" size="1" id="yt" style= "background-color:#eeeeee;width:150px;font-size:12px;" onKeyDown="catch_keydown(this);" onKeyPress="catch_press(this);">
        <option></option>
        <option>基本测量</option>
      </select>
    </font></td>
  </tr>
            </table>
            <table width="75%" border="1">
              <tr>
                <td><font size="+1">领用人</font>:</td>
                <td><font size="+1">
                  <select name="lyr" size="1" id="lyr" style= "background-color:#eeeeee;width:150px;font-size:12px;" onKeyDown="catch_keydown(this);" onKeyPress="catch_press(this);">
                    <option></option>
                  </select>
                </font></td>
              </tr>
              <tr>
                <td width="25%"><font size="+1">保管人:</font></td>
                <td width="75%"><font size="+1">
                  <input name="bgr" type="text" style= "background-color:#eeeeee;width:150px;font-size:12px;"  id="bgr" readonly value="<%=session("admin")%>" size="10" >
                </font></td>
              </tr>
              <tr>
                <td><font size="+1">领用时间</font>:</td>
                <td><font size="+1">
                  <input name="lysj" type="text"  style= "background-color:#eeeeee;width:150px;font-size:12px;" id="lysj" value="<%=Date()%>" size="10" >
                </font></td>
              </tr>
            </table>
            <p>
              <input type="submit" name="Submit23" value="提交">
              <input type="reset" name="Submit222" value="重置">
</p>
            <p>&nbsp;</p>
      </form>
      </div></td>
  </tr>
</table>
<p>&nbsp;</p>
<div align="center">
  <p>&nbsp;</p>
  <p>&nbsp;</p>
</body>
</html>


[ 本帖最后由 wwm123456789 于 2012-3-5 12:01 编辑 ]
6 回复
#2
wwm1234567892012-03-04 20:58
请各位帮忙看看,谢谢了!
#3
wangzhao85502012-03-05 11:11
没有其他方法,只有异步能解决
#4
jonathen2012-03-05 11:18
根据id在选择相应选项的时候输出相应单位就可以了吧!
#5
wwm1234567892012-03-05 12:02
谢谢各位,能否提供更具体一点的解决方案!
#6
cnfarer2012-03-05 13:51
1.ajax
2.生成js代码在选择材料时调用

[ 本帖最后由 cnfarer 于 2012-3-5 13:52 编辑 ]
#7
yms1232012-03-05 14:09
程序代码:
<!--#include file="aspcon.asp"-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>材料管理系统</title>
<script type="text/javascript" >
var curl;
//js获取url参数
function GetArgsFromHref(sHref, sArgName) {
   
var args = sHref.split("?");
   
var retval = "";
   
if (args[0] == sHref) {
        
return retval;
    }
   
var str = args[1];
    args
= str.split("&");
   
for (var i = 0; i < args.length; i++) {
        str
= args[i];
        
var arg = str.split("=");
        
if (arg.length <= 1)
            
continue;
        
if (arg[0] == sArgName)
            retval
= arg[1];
    }
   
return retval;
}
function name_Click(Val)
{
    addParm(
"ID",Val);
    self.location
=curl;
}
function addParm(pName,pValue)
{
    curl
=self.location.href;
   
if(GetArgsFromHref(pName)!="")
    {
       tValue
=GetArgsFromHref(pName);
       curl
=curl.replace(pName+"="+tValue,pName+"="+pValue);
      
return false;
    }
   
if(curl.indexOf("?")==-1)
       curl
+="?"+pName+"="+pValue;
   
else
       curl
+="&"+"pName+"="+pValue;
}
</script>
</head>
<body bgcolor=
"#CCFFFF" link="#0000FF" vlink="#0000FF" alink="#FF0000">
<center>
<table width=
"800" border="1">
  <tr>
    <td><div align=
"center">
      <h1>耗材领用登记</h1></p>
      <form name=
"form1" method="post" action="aa.asp">
        <table width=
"75%" border="1">
          <tr>
            <td><font size=
"+1">材料名称</font>:</td>
            <td><font size=
"+1">
              <select name=
"name" size="1" id="name" style= "background-color:#eeeeee;width:150px;font-size:12px;" onclick="name_Click(this.options[this.selectedIndex].value);"
onkeydown=
"catch_keydown(this);" onkeypress="catch_press(this);">
                <option></option>
                <%
                   Dim sql
                   sql=
"select distinct(name),id from rkb order by name" '去掉重复值
                   set rs=conn.execute(sql)
                   do while rs.eof=false
                      if Request(
"ID")=CStr(rs("id")) Then  
                         %><option selected value='<%=rs(
"id")%>' ><%=rs("name")%></option><%
                      else
                         %><option value='<%=rs(
"id")%>' ><%=rs("name")%></option><%
                      end if
                      rs.movenext
                  loop
               %>
              </select>
            </font></td>
          </tr>
          <tr>
            <td width=
"25%"><font size="+1">型号品牌:</font></td>
            <td width=
"75%"><font size="+1">
              <select name=
"xh" size="1" id="xh" style= "background-color:#eeeeee;width:150px;font-size:12px;" onkeydown="catch_keydown(this);" onkeypress="catch_press(this);">
                <option></option>
                <%
                    
                    if Request(
"ID")<>"" Then
                       sql=
"select distinct(xh) from rkb Where id="&Request("ID")&" order by xh" '去掉重复值
                   else
                       sql=
"select distinct(xh) from rkb order by xh" '去掉重复值
                   end if
                   set rs=conn.execute(sql)
                   do while rs.eof=false
                      %><option><%=rs(
"xh")%></option><%
                      rs.movenext
                   loop
               %>
              </select>
            </font></td>
          </tr>
          <tr>
            <td><font size=
"+1">单位</font>:</td>
            <td><font size=
"+1">
              <select name=
"dw" size="1" id="dw"  style= "background-color:#eeeeee;width:150px;font-size:12px;"   onkeydown="catch_keydown(this);" onkeypress="catch_press(this);">
                <option></option>
                <%
                 if Request(
"ID")="" Then
                    sql=
"select distinct(dw) from rkb order by dw" '去掉重复值
                 else
                    sql=
"select distinct(dw) from rkb where id="&Request("ID")&" order by dw" '去掉重复值
                 end if
                set rs=conn.execute(sql)
                 do while rs.eof=false
                    %><option><%=rs(
"dw")%></option><%
                    rs.movenext
                 loop
               %>
              </select>
            </font></td>
          </tr>
        </table>
            <table width=
"75%" border="1">
  <td width=
"25%"><font size="+1">数量:</font></td>
      <td width=
"75%"><font size="+1">
        <select name=
"sl" size="1" id="sl"  style= "background-color:#eeeeee;width:150px;font-size:12px;">
          <option>1</option>
        </select>
      </font></td>
  </tr>
  <tr>
    <td><font size=
"+1">用途:</font>:</td>
    <td><font size=
"+1">
      <select name=
"yt" size="1" id="yt" style= "background-color:#eeeeee;width:150px;font-size:12px;" onKeyDown="catch_keydown(this);" onKeyPress="catch_press(this);">
        <option></option>
        <option>基本测量</option>
      </select>
    </font></td>
  </tr>
            </table>
            <table width=
"75%" border="1">
              <tr>
                <td><font size=
"+1">领用人</font>:</td>
                <td><font size=
"+1">
                  <select name=
"lyr" size="1" id="lyr" style= "background-color:#eeeeee;width:150px;font-size:12px;" onKeyDown="catch_keydown(this);" onKeyPress="catch_press(this);">
                    <option></option>
                  </select>
                </font></td>
              </tr>
              <tr>
                <td width=
"25%"><font size="+1">保管人:</font></td>
                <td width=
"75%"><font size="+1">
                  <input name=
"bgr" type="text" style= "background-color:#eeeeee;width:150px;font-size:12px;"  id="bgr" readonly value="<%=session("admin")%>" size="10" >
                </font></td>
              </tr>
              <tr>
                <td><font size=
"+1">领用时间</font>:</td>
                <td><font size=
"+1">
                  <input name=
"lysj" type="text"  style= "background-color:#eeeeee;width:150px;font-size:12px;" id="lysj" value="<%=Date()%>" size="10" >
                </font></td>
              </tr>
            </table>
            <p>
              <input type=
"submit" name="Submit23" value="提交">
              <input type=
"reset" name="Submit222" value="重置">
</p>
            <p>&nbsp;</p>
      </form>
      </div></td>
  </tr>
</table>
<p>&nbsp;</p>
<div align=
"center">
  <p>&nbsp;</p>
  <p>&nbsp;</p>
</body>
</html>

未测试LZ可以测试一下
1