<% provid = request("provid") ' รหัสจังหวัด
sql="select provid,province from Tblprovince "
Set rs=Server.CreateObject("ADODB.Recordset")
rs.open sql,Conn,1,3
if not rs.eof then
allprov = Rs.GetRows
Item = Ubound(allprov,2)+1
end if
rs.close
%>
<form action="test2.asp" name='form'>
ชื่อจังหวัด <select name='provid' onchange='form.submit();'>
<%for i = 0 to item - 1%>
<option value='<%=allprov(0,i)%>'><%=allprov(1,i)%></option>
<%next%>
</select>
<%
if len(provid) = 0 then
provid=0
end if
sql="select cityid,cityname from Tblcity where provid = "& provid
Set rs=Server.CreateObject("ADODB.Recordset")
rs.open sql,Conn,1,3
if not rs.eof then
allcity = Rs.GetRows
nItem = Ubound(allcity,2)+1
end if
rs.close
%>
ชื่ออำเภอ : <select name='city'> <option value=''>-------เลือกชื่ออำเภอ--------</option>
<%
if nitem > 0 then
for x = 0 to nItem - 1%>
<option value='<%=allcity(0,x)%>'><%=allcity(1,x)%></option>
<%
next
end if
%>
</select>
</form>
Tag : - - - -
Date :
8 พ.ย. 2548 14:30:15
By :
bit69
View :
3111
Reply :
1
No. 1
Guest
<%
provid = request("provid") ' รหัสจังหวัด
province = request("product_name")
sql="select provid,province from Tblprovince "
Set rs=Server.CreateObject("ADODB.Recordset")
rs.open sql,Conn,1,3
if provid <> "" then
sql1="select cityid,cityname from Tblcity where provid = "&provid
Set rs1=Server.CreateObject("ADODB.Recordset")
rs1.open sql1,Conn,1,3
end if
%>
<select name="province" onchange="location.href=this.value">
<option value="<%=provid%>" selected><%=province%></option>
<% do while not rs.eof %>
<option value="test2.asp?provid=<%=rs("provid")%>&province=<%=rs("province")%>"><%=rs("province")%></option>
<% rs.movenext
loop %>
</select>
<% if provid <> "" then
if not rs1.eof then %>
<select name="city">
<% do while not rs1.eof %>
<option value="<%=rs1("cityid")%>"><%=rs1("cityname")%></option>
<% rs1.movenext
loop %>
</select>
<% end if
end if%>