标题:纯ASP四级联动结合ACCESS数据库
只看楼主
smh4037
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2008-6-21
 问题点数:0 回复次数:3 
纯ASP四级联动结合ACCESS数据库
纯ASP四级联动....有没有更好的办法

这个还有一点缺陷,,,,,,,

|中国区域|省|市|县|

<!--#include file="../conn/conn.asp"-->
<%

Function SercahDei(Deiid,shengid,shiid,xiangid)
 If Deiid = "" Then
    Deiid = 1
 Else
    Deiid  = Int(Deiid)
 End If
 Str    = "<form action='' method='post' name='form1'>"
 Set rs = Server.CreateObject("ADODB.RecordSet")
 Sql    = "Select * From MT_sshqdei"
 rs.Open Sql,conn,1,1
 Str = Str &"<select name='deiid' onchange=document.form1.submit();>"
 Do While Not rs.Eof
 If Deiid = rs("id") then
 Str = Str &"<option value="&rs("id")&" selected>"&rs("deiname")&"</option>"
 else
 Str = Str &"<option value="&rs("id")&">"&rs("deiname")&"</option>"
 end if
 rs.MoveNext    
 Loop
 Str = Str &"</select>"
      If shengid = "" Then
         shengid = 1
      Else
         shengid = Int(shengid)
      End If
        Set rs1  = Server.CreateObject("ADODB.RecordSet")
        Sql      = "Select * From MT_province Where deiid="&Deiid
        rs1.Open Sql,conn,1,1
        If rs1.Eof And rs1.Bof Then
        Str = Str &""
        Else
        Str = Str &"<select name='shengid' onchange=document.form1.submit();>"
        Do While Not rs1.Eof
        if shengid = rs1("id") then
        Str = Str &"<option value="&rs1("id")&" selected>"&rs1("shengname")&"</option>"
        else
        Str = Str &"<option value="&rs1("id")&">"&rs1("shengname")&"</option>"
        end if
        rs1.MoveNext
        Loop
        Str = Str &"</select>"
        End If
        rs1.Close
        Set rs1 = Nothing
        
        
        
        
              If shiid = "" Then
                 shiid = 1
              Else
                 shiid  = Int(shiid)
              End If
        Set rs1 = Server.CreateObject("ADODB.RecordSet")
        Sql    = "Select * From MT_city Where shengid="&shengid&" and deiid="&Deiid
        rs1.Open Sql,conn,1,1
        If rs1.Eof And rs1.Bof Then
        Str = Str &""
        Else
        Str = Str &"<select name='shiid' onchange=document.form1.submit();>"
        Do While Not rs1.Eof
        if shiid = rs1("id") then
        Str = Str &"<option value="&rs1("id")&" selected>"&rs1("shiname")&"</option>"
        else
        Str = Str &"<option value="&rs1("id")&">"&rs1("shiname")&"</option>"
        end if
        rs1.MoveNext
        Loop
        Str = Str &"</select>"
        End If
        rs1.Close
        Set rs1 = Nothing
        
        
        
        
        
              If xiangid = "" Then
                 xiangid = 1
              Else
                 xiangid  = Int(xiangid)
              End If
        Set rs1 = Server.CreateObject("ADODB.RecordSet")
        Sql    = "Select * From MT_xiang Where shiid="&shiid&" and deiid="&Deiid
        rs1.Open Sql,conn,1,1
        If rs1.Eof And rs1.Bof Then
        Str = Str &""
        Else
        Str = Str &"<select name='xiangid' onchange=document.form1.submit();>"
        Do While Not rs1.Eof
        if xiangid = rs1("id") then
        Str = Str &"<option value="&rs1("id")&" selected>"&rs1("xiangname")&"</option>"
        else
        Str = Str &"<option value="&rs1("id")&">"&rs1("xiangname")&"</option>"
        end if
        rs1.MoveNext
        Loop
        Str = Str &"</select>"
        End If
        rs1.Close
        Set rs1 = Nothing

      
 rs.Close
 Set rs = Nothing
 Str    = Str &"</form>"
 SercahDei = Str
 End Function

deiid    = Trim(Request.Form("deiid"))
shengid  = Trim(Request.Form("shengid"))
shiid    = Trim(Request.Form("shiid"))
xiangid  = Trim(Request.Form("xiangid"))

Response.Write SercahDei(Deiid,shengid,shiid,xiangid)
Response.Write Deiid&","&shengid&","&shiid&","&xiangid
%>

四级联动(纯ASP).jpg (5.29 KB)
搜索更多相关主题的帖子: 四级 数据库 ACCESS ASP 中国 
2008-06-21 22:23
天涯听雨
Rank: 2
来 自:东莞
等 级:论坛游民
威 望:4
帖 子:497
专家分:64
注 册:2007-8-25
得分:0 
我晕死,分几个表的。。。。。。

一般向前台这样地市几级连动的,都是生成JS代码的。

从明天起做幸福的人,喂马劈柴周游世界!
2008-06-22 22:59
anlige
Rank: 3Rank: 3
等 级:新手上路
威 望:7
帖 子:401
专家分:0
注 册:2006-11-3
得分:0 
ajax,一个表,利用产业部全国县市数据实现3级联动
http://blog.文件列表里有具体代码

http://www.
zhanghuiguoanlige@
2008-06-24 06:32
smh4037
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2008-6-21
得分:0 
不懂JS,所以才做得这么麻烦
2008-06-24 20:50



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-220454-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.289074 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved