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