3级下拉联动菜单

默认分类 未结 1 610
_DJ___PEbgj°
_DJ___PEbgj° 2023-03-21 09:22
相关标签:
1条回答
  • 2023-03-21 10:08

    <% set conn=Server.CreateObject("ADODB.Connection") dbpath=Server.MapPath("db1.mdb") conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Database Password=;Data Source=" & dbpath dim SelectStr SelectStr = "" dim sql1,sql2,sql3 dim rs1,rs2,rs3 dim i1,i2,i3 '使用缓存,application("liststr"),将添加,编辑或删除一个数据时,用application("liststr") = empty清空缓存 application("liststr") = empty if isempty(application("liststr")) then '//一级分类开始 sql1 = "select c1id,c1name from class1" set rs1 = conn.execute(sql1) i1 = 0 while not rs1.eof if i1 > 0 then SelectStr = SelectStr & "||" end if SelectStr = SelectStr & rs1("c1name") & "{{" '显示与值不同时,用下面一行 'SelectStr = SelectStr & rs1("c1name") & "@"& rs1("c1id") &"{{" '//二级分类开始 sql2 = "select c2id,c2name from class2 where c1name = '"& replace(rs1("c1name"),"'","''") &"'" set rs2 = conn.execute(sql2) i2 = 0 while not rs2.eof if i2 > 0 then SelectStr = SelectStr & "**" end if SelectStr = SelectStr & rs2("c2name") & "((" '显示与值不同时,用下面一行 'SelectStr = SelectStr & rs2("c2name") & "@"& rs2("c2id") &"((" '//*分类开始 sql3 = "select c3id,c3name from class3 where c2name = '"& replace(rs2("c2name"),"'","''") &"'" set rs3 = conn.execute(sql3) i3 = 0 while not rs3.eof if i3 > 0 then SelectStr = SelectStr & "^" end if SelectStr = SelectStr & rs3("c3name") '显示与值不同时,用下面一行 'SelectStr = SelectStr & rs3("c3name") & "@" & rs3("c3id") i3 = i3 + 1 rs3.movenext wend rs3.close set rs3 = nothing '//*分类结束 i2 = i2 + 1 rs2.movenext wend rs2.close set rs2 = nothing '//二级分类结束 i1 = i1 + 1 rs1.movenext wend rs1.close set rs1 = nothing application("liststr") = SelectStr end if '//一级分类结束 %>


    选择一次

    选择三次
    或者 <% dim cid,coid cid = request("cid") 'cid 大类id coid = request("coid") 'coid 中类id set rs=server.createobject("adodb.recordset") sql = "select * from e_c" '表一 大类表 rs.open sql,conn,1,1 strOption1 = "" do while not rs.eof if cstr(rs("id")) = cstr(cid) then strOption1 = strOption1 & "" else strOption1 = strOption1 & "" end if rs.movenext &nbs p; loop rs.close if cid <> "" then sql = "select * from e_co where c_id=" & cid '表二 中类表 bid==表一中的id rs.open sql,conn,1,1 strOption2 = "" do while not rs.eof if cstr(rs("id")) = cstr(coid) then strOption2 = strOption2 & "" else strOption2 = strOption2 & "" &nbs p; end if rs.movenext loop rs.close end if if coid <> "" then sql = "select * from e_s where co_id= " & coid '表三 小类表 mid==表二的id rs.open sql,conn,1,1 strOption3 = "" while not rs.eof if cstr(rs("id")) = cstr(sid) then strOption3 = strOption3 & "" else strOption3 = strOption3 & "" end if rs.movenext wend rs.close end if %>

    0 讨论(0)
提交回复