三级联动菜单 PENGHAO

<!--#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 onchange="changeb(this.value)" name="bid"><%=strOption1%></select> 
<select onchange="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> 
原文地址:https://www.cnblogs.com/Dove/p/118248.html