ASP

本类阅读TOP10

·asp常用数据库连接方法和技巧
·无组件生成BMP验证码
·一些常用的辅助代码 (网络收藏)
·JavaScript实现的数据表格:冻结列、调整列宽和客户端排序
·VisualStudio.NET_2003及其 MSDN 下载地址
·ASP模拟MVC模式编程
·图片以二进制流输出到网页
·MD5加密算法 ASP版
·ASP.NET编程中的十大技巧
·改进 ASP 的字符串处理性能

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
基于数据库的三级菜单实现(二级同理)

作者:未知 来源:月光软件站 加入时间:2005-5-13 月光软件站

<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>




相关文章

相关软件