三级联动菜单

<!--#include file="conn.asp"-->
<%
    dim bid,cid
    bid = request("bid")  'bid   大类id
    cid = request("cid")   'cid  中类id

 'if bid="" then
    'bid="1"
    'end if
 'if cid="" then
    'cid="1"
    'end if
 
     set rs=server.createobject("adodb.recordset")  
     sql = "select * from btype"    '表一  大类表
     rs.open sql,conn,1,3
     strOption1 = "<option value='' selected style='BACKGROUND-COLOR: #eeeeee; COLOR: #ff0000'>==请选择==</option>"
           do while not rs.eof
           if cstr(rs("id")) = cstr(bid) then
                 strOption1 = strOption1 & "<option value='" & rs("id") & "' selected>" & rs("type") & "</option>"
           else
    
          strOption1 = strOption1 & "<option value='" & rs("id") & "'>" & rs("type") & "</option>"
           
     end if
     rs.movenext      
            loop   
 
     rs.close
    
     if bid <> "" then
           sql = "select * from mtype where bid=" & bid   '表二  中类表   bid==表一中的id
        
     rs.open sql,conn,1,3
           strOption2 = "<option value='' selected style='BACKGROUND-COLOR: #eeeeee; COLOR: #ff0000'>==请选择==</option>"
   
           do while not rs.eof
                 if cstr(rs("id")) = cstr(cid) then
                       strOption2 = strOption2 & "<option value='" & rs("id") & "' selected>" & rs("type") & "</option>"
                 else
                       strOption2 = strOption2 & "<option value='" & rs("id") & "'>" & rs("type") & "</option>"
                 end if
        rs.movenext
           loop
           rs.close
     end if
    
     if cid <> "" then
           sql = "select * from stype where mid= " & cid  '表三   小类表  mid==表二的id
           rs.open sql,conn,1,3
           strOption3 = "<option value='' selected style='BACKGROUND-COLOR: #eeeeee; COLOR: #ff0000'>==请选择==</option>"
           while not rs.eof
           if cstr(rs("id")) = cstr(cid) then
                       strOption3 = strOption3 & "<option value='" & rs("id") & "' selected>" & rs("type") & "</option>"
                 else
                       strOption3 = strOption3 & "<option value='" & rs("id") & "'>" & rs("type") & "</option>"
                 end if
                 'strOption3 = strOption3 & "<option value='" & rs("id") & "'>" & rs("type") & "</option>"
         
           rs.movenext
           wend
     rs.close
     end if
    
%>
<select οnchange="changeb(this.value)" name="bid"><%=strOption1%></select>
<select οnchange="change(this.value)" name="cid"><%=strOption2%></select>
<select name="typeid"><%=strOption3%></select>
<script language="javascript">
<!--
     function changeb(bid){
           location.assign("three.asp?bid=" + bid);  
     }
    
     function change(cid){
           location.assign("three.asp?bid=<%=bid%>&cid=" + cid);   
     }
-->
</script>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值