| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 699 人关注过本帖
标题:请教下拉列表级联问题(已重新编辑,图可见,附源码)。
只看楼主 加入收藏
wwm123456789
Rank: 4
等 级:业余侠客
帖 子:63
专家分:204
注 册:2010-4-4
结帖率:92.86%
收藏
已结贴  问题点数:20 回复次数:6 
请教下拉列表级联问题(已重新编辑,图可见,附源码)。
数据库结构及数据如图
图片附件: 游客没有浏览图片的权限,请 登录注册

网页界面如图
图片附件: 游客没有浏览图片的权限,请 登录注册
,希望实现的功能是,当我选择的
材料名称为“打印纸”时,
型号品牌中选项只有"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 编辑 ]
搜索更多相关主题的帖子: 打印纸 数据库 color 网页 
2012-03-03 18:25
wwm123456789
Rank: 4
等 级:业余侠客
帖 子:63
专家分:204
注 册:2010-4-4
收藏
得分:0 
请各位帮忙看看,谢谢了!
2012-03-04 20:58
wangzhao8550
Rank: 3Rank: 3
等 级:论坛游侠
威 望:3
帖 子:32
专家分:139
注 册:2011-4-17
收藏
得分:3 
没有其他方法,只有异步能解决
2012-03-05 11:11
jonathen
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:32
专家分:134
注 册:2012-2-14
收藏
得分:3 
根据id在选择相应选项的时候输出相应单位就可以了吧!
2012-03-05 11:18
wwm123456789
Rank: 4
等 级:业余侠客
帖 子:63
专家分:204
注 册:2010-4-4
收藏
得分:0 
谢谢各位,能否提供更具体一点的解决方案!
2012-03-05 12:02
cnfarer
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:179
帖 子:3330
专家分:21157
注 册:2010-1-19
收藏
得分:3 
1.ajax
2.生成js代码在选择材料时调用

[ 本帖最后由 cnfarer 于 2012-3-5 13:52 编辑 ]

★★★★★为人民服务★★★★★
2012-03-05 13:51
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:11 
程序代码:
<!--#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可以测试一下
2012-03-05 14:09
快速回复:请教下拉列表级联问题(已重新编辑,图可见,附源码)。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.029577 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved