首页 | 站长免费中心 | 新手上路 | 网站运营 | 网页制作 | 图片设计 | 动画设计 | 网页编程 | 网页特效 | 本站专题 | 虚拟主机 | 域名注册 | 网站建设 | 程序下载
       免费空间资源 | 新闻咨询 | 免费域名 | 免费网盘 | 网站推广 | 网站策划 | 建站经验 | 网站优化 | 网页代码 | 源码下载 | 音乐小偷 | 网络赚钱 | 论坛交流
网站建设
网站建设
虚拟主机
虚拟主机
域名注册
域名注册
711网络首页
站长工具
站长工具
网站源码
网站源码
站长论坛
站长论坛

 711网络 网页编程ASP代码

三级联动下拉列表[数据库版]

来源: 互联网    日期:2007-1-13 15:10:48
 

    <%
    set rs=server.createobject("adodb.recordset")
    rs.open"select * from class_two",conn,1,1
    %>
    ‘---------以上是查询出第一级下拉列表的内容-----
     ’---------以下是用JS来控制程序--------------
    <script language = "javascript">
    var onecount; //定义onecount对像
    onecount=0;//初始值为0
    subcat = new Array(); //SUBCAT对像是一个新的数组
    <%
    count = 0 '定义count对像初始值为0
    do while not rs.eof '循环表头到表尾
    %>
    subcat[<%=count%>] = new Array("<%=rs("class_two_text")%>","<%=trim(rs("class_one"))%>","<%=trim(rs("class_two"))%>");
    //以上为重点内容,对像数组(subcat[count对像值])= 新数组内容('字段名0','字段名1','字段名2')记住要对应
    <%
    count = count + 1 '循环count一次,COUNT的值加1
    rs.movenext
    loop
    rs.close
    %>
    onecount=<%=count%>;
    function changelocation(locationid)
     {
     document.form.class_two.length = 0;
     var locationid=locationid;
     var i;
     for (i=0;i < onecount; i++)
    {
     if (subcat[1] == locationid)
     {
    document.form.class_two.options[document.form.class_two.length] = new Option(subcat[0], subcat[2]);
     }
    }
     }
    </script>
    <%
    set rs=server.CreateObject("adodb.recordset")
    rs.open "select * from Class_one" ,conn,1,1
    if rs.eof then
    response.Write"暂无产品一类名称"
    else%>
    产品一类
    <select name="class_one" id="class_one"
    onChange="changelocation(document.form.class_one.options[document.form.class_one.selectedIndex].value)">
     <%do while not rs.eof%>
     <option value="<%=rs("class_one")%>"><%=rs("class_one_text")%></option>
     <%rs.movenext
     loop
     end if
     %>
    </select>
    产品二类
    <select name="class_two"
    onChange="three(document.form.class_one.value,document.form.class_two.options[document.form.class_two.selectedIndex].value)">
    <option value="请选择条件" selected>请选择条件</option>
    </select> <%
    set rs=server.createobject("adodb.recordset")
    rs.open"select * from class_three",conn,1,1
    %> <script language = "javascript">
    var twocount;
    twocount=0;
    subthree = new Array();
    <%
    countb = 0
    do while not rs.eof
    %>
    subthree[<%=countb%>] = new
    Array("<%=rs("class_three_text")%>","<%=trim(rs("class_one"))%>","<%=trim(rs("class_two"))%>","<%=trim(rs("class_three"))%>");
    <%
    countb = countb + 1
    rs.movenext
    loop
    rs.close
    %>
    twocount=<%=countb%>;
    function three(threeid,threeid2)
     {
     document.form.class_three.length = 0;
     var threeid=threeid;
     var threeid2=threeid2;
     var i;
     for (i=0;i < twocount; i++)
    {
     if ((subthree[1] == threeid) & (subthree[2] == threeid2))
     {
    document.form.class_three.options[document.form.class_three.length] = new Option(subthree[0],
    subthree[3]);
     }
    }
     }
    </script>
    产品三类
    <select name="class_three" id="class_three">
    <option value="0" selected>请选择条件</option>
    </select>  [转自:711网络工作室 http://www.tc711.com]



更多的三级联动下拉列表[数据库版]请到论坛查看: http://BBS.TC711.COM



【 双击滚屏 】 【 评论 】 【 收藏 】 【 打印 】 【 关闭 】 来源: 互联网    日期:2007-1-13 15:10:48   

上一篇:前进后退按钮..
发 表 评 论
查看评论

  您的大名:
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款
认证编码: 刷新验证码
点评内容: 字数0
  精品推荐  
  本月推荐  
  友情赞助  

关于我们 | 联系我们 | 广告投放 | 留言反馈 | 免费程序 | 虚拟主机 | 网站建设 |  网站推广 |  google_sitemap baidu_sitemap RSS订阅
本站所有资源均来自互联网,如有侵犯您的版权或其他问题,请通知管理员,我们会在最短的时间回复您
Copyright © 2005-2015 Tc711.Com All Rights Reserved 版权所有·711网络   蜀ICP备05021915号
110网监备案 信息产业备案 不良信息举报