第一步,我先设计了个access数据库,做了一张存储省市区字段的表,至于其他字段就没给出了,重点是在于地区的字段。。。
表的设计:
检索地区
微站搜索:
if wxareaid = 0 and act = "selectedProvince" then
sql = "select distinct AreaName1, Areaid1 from [Area] where AreaName1 <>''"
str = "0|||"
else
if act = "changeCity" or act = "selectedCity" then
sql = "select distinct AreaName2, Areaid2 from [Area] where Areaid1="& wxareaid &" and AreaName2 <> ''"
str = "1|||"
end if
if act = "changeArea" or act = "selectedArea" then
sql = "select distinct AreaName3, Areaid3 from [Area] where Areaid2="& wxareaid &" and AreaName3 <> ''"
str = "2|||"
end if
end if
if not rs.eof then
selected = ""
while not rs.eof
if selectedid = 0 then
selected = ""
else
if format_id(selectedid) = format_id(rs(1)) then
selected = " selected='selected'"
else
selected = ""
end if
end if
str = str & ""
rs.movenext
wend
end if
而选中状态则是直接通过传过来的selectedid来和areaid对比得到。。
最终演示结果:
到这里,就是整个下拉框触发和选中的写法了,源代码我已经传到附件上,具体点击下面:
http://download.csdn.net/detail/eadio/8059797