(地址级联)省市两级级联(通过js实现)
jsp文件中代码片段如下:
<tr>
<th>单位住址</th>
<td><select id="provinceCompany" name="provinceCompany" onchange="selectCompanyCity(this.value);" style="width:80px"></select>
<select id="areaCompany" name="areaCompany" style="width:100px"> </select>
</td>
</tr>
<div style="display:none;">
<input id="dwProvinceCompany" name="dwProvinceCompany" value="${student.dwProvinceCompany}"/>
<input id="dwAreaCompany" name="dwAreaCompany" value="${student.dwAreaCompany}"/>
</div>
js文件内容如下:
var city=[{name:'请选择',subCity:[{name:'请先选择省份'}]},{name:'北京',
subCity:[
{name:'请选择'},
{name:'东城区'},
{name:'西城区'},
{name:'崇文区'},
{name:'宣武区'},
{name:'朝阳区'},
{name:'丰台区'},
{name:'石景山区'},
{name:'海淀区'},
{name:'门头沟区'},
{name:'房山区'},
{name:'通州区'},
{name:'顺义区'},
{name:'昌平区'},
{name:'大兴区'},
{name:'怀柔区'},
{name:'平谷区'},
{name:'密云区'},
{name:'延庆区'}]},
{name:'天津',
subCity:[{name:'请选择'},
{name:'和平区'},
{name:'河东区'},
{name:'河西区'},
{name:'南开区'},
{name:'河北区'},
{name:'红桥区'},
{name:'塘沽区'},
{name:'汉沽区'},
{name:'大港区'},
{name:'东丽区'},
{name:'西青区'},
{name:'津南区'},
{name:'北辰区'},
{name:'武清区'},
{name:'宝坻区'}]},
{name:'河北',
subCity:[{name:'请选择'},
{name:'石家庄市'},
{name:'唐山市'},
{name:'秦皇岛市'},
{name:'邯郸市'},
{name:'邢台市'},
{name:'保定市'},
{name:'张家口市'},
{name:'承德市'},
{name:'沧州市'},
{name:'廊坊市'},
{name:'衡水市'}]},
{name:'山西',
subCity:[{name:'请选择'},
{name:'太原市'},
{name:'大同市'},
{name:'阳泉市'},
{name:'长治市'},
{name:'晋城市'},
{name:'朔州市'},
{name:'晋中市'},
{name:'运城市'},
{name:'忻州市'},
{name:'临汾市'},
{name:'吕梁市'}]},
{name:'内蒙古',
subCity:[
{name:'请选择'},
{name:'呼和浩特市'},
{name:'包头市'},
{name:'乌海市'},
{name:'赤峰市'},
{name:'通辽市'},
{name:'鄂尔多斯市'},
{name:'呼伦贝尔市'},
{name:'巴彦淖尔市'},
{name:'乌兰察布市'},
{name:'兴安盟'},
{name:'锡林郭勒盟'},
{name:'阿拉善盟'}]},
{name:'辽宁',
subCity:[
{name:'请选择'},
{name:'沈阳市'},
{name:'大连市'},
{name:'鞍山市'},
{name:'抚顺市'},
{name:'本溪市'},
{name:'丹东市'},
{name:'锦州市'},
{name:'营口市'},
{name:'阜新市'},
{name:'辽阳市'},
{name:'盘锦市'},
{name:'铁岭市'},
{name:'朝阳市'},
{name:'葫芦岛市'}]},
{name:'吉林',
subCity:[{name:'请选择'},
{name:'长春市'},
{name:'吉林市'},
{name:'四平市'},
{name:'辽源市'},
{name:'通化市'},
{name:'白山市'},
{name:'松原市'},
{name:'白城市'},
{name:'延边朝鲜族自治州'}]},
{name:'黑龙江',
subCity:[{name:'请选择'},
{name:'哈尔滨市'},
{name:'齐齐哈尔市'},
{name:'鸡西市'},
{name:'鹤岗市'},
{name:'双鸭山市'},
{name:'大庆市'},
{name:'伊春市'},
{name:'佳木斯市'},
{name:'七台河市'},
{name:'牡丹江市'},
{name:'黑河市'},
{name:'绥化市'},
{name:'大兴安岭地区'}]},
{name:'上海',
subCity:[{name:'请选择'},
{name:'黄浦区'},
{name:'卢湾区'},
{name:'徐汇区'},
{name:'长宁区'},
{name:'静安区'},
{name:'普陀区'},
{name:'闸北区'},
{name:'虹口区'},
{name:'杨浦区'},
{name:'闵行区'},
{name:'宝山区'},
{name:'嘉定区'},
{name:'浦东新区'},
{name:'金山区'},
{name:'松江区'},
{name:'青浦区'},
{name:'南汇区'},
{name:'奉贤区'}]},
{name:'江苏',
subCity:[{name:'请选择'},
{name:'南京市'},
{name:'无锡市'},
{name:'徐州市'},
{name:'常州市'},
{name:'苏州市'},
{name:'南通市'},