• 软件测试技术
  • 软件测试博客
  • 软件测试视频
  • 开源软件测试技术
  • 软件测试论坛
  • 软件测试沙龙
  • 软件测试资料下载
  • 软件测试杂志
  • 软件测试人才招聘
    暂时没有公告

字号: 小 中 大 | 推荐给好友 上一篇 | 下一篇

基于数据库的三级菜单实现(二级同理)

发布: 2007-6-30 18:56 | 作者: admin | 来源: | 查看: 75次 | 进入软件测试论坛讨论

领测软件测试网   
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0"  class="font">
  <tr> 
      <td height="44" align="right">产品编号:</td>
      <td align="left"><input name="pro_id"></td>
    </tr>
   <tr> 
      <td height="41" align="right"> 
        <%
set rs=server.CreateObject("adodb.recordset")
sq="select * from pro_big_part"
rs.open sq,conn,1,1%>
        <select  name="big_part"  onChange="ld();ld2()">
          <option value="" selected>选择一级目录</option>
          <%while not rs.eof%>
          <option value="<%=rs("big_part")%>"><%=rs("big_part")%></option>
          <%rs.movenext
wend
rs.close%>
        </select> </td>
      <td align="left"> <select  name="small_part" onChange="ld2()">
          <option value="" selected>选择二级目录</option>
        </select> &nbsp; <select  name="thr_part">
          <option value="" selected>选择三级目录</option>
        </select> 
        <%sql="select * from pro_small_part"
rs.open sql,conn,1,1
num=rs.recordcount
str=""
for i=1 to rs.recordcount
str=str&rs("big_part")&"-"&rs("small_part")&","
if rs.eof then exit for
rs.movenext
next
rs.close
%>
<%sql="select * from pro_thr_part"
rs.open sql,conn,1,1
num2=rs.recordcount
str2=""
for i=1 to rs.recordcount
str2=str2&rs("small_part")&"-"&rs("thr_part")&","
if rs.eof then exit for
rs.movenext
next
rs.close
%>
<!--下面是实现动态改变下一级菜单的脚本代码-->
        <script  LANGUAGE="javascript">
arr="<%=str%>".split(",");
a=arr.length
ar=new Array()
for (i=0;i<a;i++){
  ar[i]=arr[i].split("-");
}
onecount=ar.length;
arr2="<%=str2%>".split(",");
a2=arr2.length
ar2=new Array()
for (i=0;i<a2;i++){
  ar2[i]=arr2[i].split("-");
}
onecount2=ar2.length;
function  ld() {
  document.form1.small_part.length=0
  lid=form1.big_part.value;       
  for  (i=0;i<onecount;i++)  { 
    if  (ar[i][0]  ==  lid) {
   document.form1.small_part.options.add(new Option(ar[i][1],  ar[i][1]));    
    }    
  }   
}   
function  ld2() {
  document.form1.thr_part.length=0
  lid2=form1.small_part.value;       
  for  (i=0;i<onecount2;i++)  { 
    if  (ar2[i][0]  ==  lid2) {
   document.form1.thr_part.options.add(new Option(ar2[i][1],  ar2[i][1]));    
    }    
  }   
}   
</script></td>
    </tr></table>

文章来源于领测软件测试网 https://www.ltesting.net/


关于领测软件测试网 | 领测软件测试网合作伙伴 | 广告服务 | 投稿指南 | 联系我们 | 网站地图 | 友情链接
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:[email protected] 电话:010-51297073

软件测试 | 领测国际 | ISTQB | ISTQB官网 | TMMi | TMMi认证 | 国际软件测试工程师认证 | 领测软件测试网