日期:2014-05-16  浏览次数:20372 次

求助。地区分类里,加区县的方法。
比如有这样的数组。
var cityArr = [
["CategoryName","ParentId","Id"],
["北京","0","1"],
["重庆","0","2"],
["上海","0","3"],
["天津","0","4"],

["河北","0","5"],
["石家庄","5","101090101","S"],
["保定","5","101090201","B"],
["承德市","5","101090402","C"],
["沧州","5","101090701","C"],
["衡水","5","101090801","H"],
["邯郸","5","101091001","H"],
["廊坊","5","101090601","L"],
["秦皇岛","5","101091101","Q"],
["唐山","5","101090501","T"],
["邢台","5","101090901","X"],
["张家口","5","101090301","Z"],
]

现在有三个select
第一个是”省“,第二个是对应的省”诚市“ 第三个是”区县“

现在,当第一个选省时比如”河北“,第二个就调对应的 ”城市“数据提供选择,比如 石家庄,保定……等等,

我的问题是:

当第二个选了对应”城市“数据时,我要怎么样做,在第三个调出对应的区县。

这三级联动关系的数据,我以存在数据表里,我要把数据表导成什么样的形式,Js联动代码,我应该怎样写,才能实现此功能呢,可以举一个例子不哟????

比如,

”石家庄“ 对应的区县为 ”AB“,”AC“…………

还请高手指点一下。


------解决方案--------------------
有很多现成的代码,你搜索一个参考吧。
------解决方案--------------------
用ajax為每次請求的數據進行聯動吧
------解决方案--------------------
介个
------解决方案--------------------
弄好关联关系就行了
------解决方案--------------------
分别对每个select添加onchange事件,事件里发送ajax请求,级联都不用再前台做了,后台直接返回值。