jQuery 实现多级联动
2015-03-26 21:30
351 查看
html代码
<tr>
<td style="text-align:right;font-size:12px;">省:</td>
<td>
<input id="province" name="province"/>
</td>
</tr>
<tr>
<td style="text-align:right;font-size:12px;">市(州):</td>
<td>
<input id="city" name="city" size="22"/>
/td>
<td style="text-align:right;font-size:12px;">县(区,市,特区):</td>
<td>
<input id="county" name="county" size="22"/>
</td>
<td style="text-align:right;font-size:12px;">乡(镇):</td>
<td>
<input id="towns" name="towns" size="22"/>
/td>
<td style="text-align:right;font-size:12px;">街(村):</td>
<td>
<input id="street" name="street" size="22"/>
</td>
</tr>
js文件
<script type="text/javascript">
//先初始化对象
$(function(){
$('#province').combobox({
url:'<%=path %>/controller/dictionary/getAddress.json?parentCode=1',
width: 173,
panelHeight: "auto",
editable: false,
valueField: 'code',
textField: 'area',
onLoadSuccess: function () {
//加载完成后,设置选中第一项
/* var val = $(this).combobox("getData");
for (var item in val[0]) {
if (item == "code") {
$(this).combobox("select", val[0][item]);
}
} */
},
onChange: function () {
//更新下一级列表
$('#city').combobox('reload', "<%=path %>/controller/dictionary/getAddress.json?parentCode=" + $(this).combobox("getValue"));
}
});
$('#city').combobox({
width: 173,
panelHeight: "auto",
editable: false,
valueField: 'code',
textField: 'area',
onLoadSuccess: function () {
//加载完成后,设置选中第一项
},
onChange: function () {
//更新市列表
$('#county').combobox('reload', "<%=path %>/controller/dictionary/getAddress.json?parentCode=" + $(this).combobox("getValue"));
}
});
$('#county').combobox({
width: 173,
panelHeight: "auto",
editable: false,
valueField: 'code',
textField: 'area',
onLoadSuccess: function () {
},
onChange: function () {
//更新市列表
$('#towns').combobox('reload', "<%=path %>/controller/dictionary/getAddress.json?parentCode=" + $(this).combobox("getValue"));
}
});
$('#towns').combobox({
width: 173,
panelHeight: "auto",
editable: false,
valueField: 'code',
textField: 'area',
onLoadSuccess: function () {
},
onChange: function () {
//更新市列表
$('#street').combobox('reload', "<%=path %>/controller/dictionary/getAddress.json?parentCode=" + $(this).combobox("getValue"));
}
});
$('#street').combobox({
width: 173,
panelHeight: "auto",
editable: false,
valueField: 'code',
textField: 'area',
onLoadSuccess: function () {
}
});
});
</script>
<tr>
<td style="text-align:right;font-size:12px;">省:</td>
<td>
<input id="province" name="province"/>
</td>
</tr>
<tr>
<td style="text-align:right;font-size:12px;">市(州):</td>
<td>
<input id="city" name="city" size="22"/>
/td>
<td style="text-align:right;font-size:12px;">县(区,市,特区):</td>
<td>
<input id="county" name="county" size="22"/>
</td>
<td style="text-align:right;font-size:12px;">乡(镇):</td>
<td>
<input id="towns" name="towns" size="22"/>
/td>
<td style="text-align:right;font-size:12px;">街(村):</td>
<td>
<input id="street" name="street" size="22"/>
</td>
</tr>
js文件
<script type="text/javascript">
//先初始化对象
$(function(){
$('#province').combobox({
url:'<%=path %>/controller/dictionary/getAddress.json?parentCode=1',
width: 173,
panelHeight: "auto",
editable: false,
valueField: 'code',
textField: 'area',
onLoadSuccess: function () {
//加载完成后,设置选中第一项
/* var val = $(this).combobox("getData");
for (var item in val[0]) {
if (item == "code") {
$(this).combobox("select", val[0][item]);
}
} */
},
onChange: function () {
//更新下一级列表
$('#city').combobox('reload', "<%=path %>/controller/dictionary/getAddress.json?parentCode=" + $(this).combobox("getValue"));
}
});
$('#city').combobox({
width: 173,
panelHeight: "auto",
editable: false,
valueField: 'code',
textField: 'area',
onLoadSuccess: function () {
//加载完成后,设置选中第一项
},
onChange: function () {
//更新市列表
$('#county').combobox('reload', "<%=path %>/controller/dictionary/getAddress.json?parentCode=" + $(this).combobox("getValue"));
}
});
$('#county').combobox({
width: 173,
panelHeight: "auto",
editable: false,
valueField: 'code',
textField: 'area',
onLoadSuccess: function () {
},
onChange: function () {
//更新市列表
$('#towns').combobox('reload', "<%=path %>/controller/dictionary/getAddress.json?parentCode=" + $(this).combobox("getValue"));
}
});
$('#towns').combobox({
width: 173,
panelHeight: "auto",
editable: false,
valueField: 'code',
textField: 'area',
onLoadSuccess: function () {
},
onChange: function () {
//更新市列表
$('#street').combobox('reload', "<%=path %>/controller/dictionary/getAddress.json?parentCode=" + $(this).combobox("getValue"));
}
});
$('#street').combobox({
width: 173,
panelHeight: "auto",
editable: false,
valueField: 'code',
textField: 'area',
onLoadSuccess: function () {
}
});
});
</script>
相关文章推荐
- jquery 实现二级/三级/多级联动菜单的思路及代码
- jQuery实现多级联动下拉列表查询框
- jQuery实现的多选框多级联动插件
- jQuery插件实现多级联动菜单效果
- 用Jquery实现多级下拉框无刷新的联动
- jQuery实现多级联动下拉列表查询框
- jquery实现多级联动
- jQuery实现的多选框多级联动插件
- jQuery插件实现多级联动菜单效果
- Jquery实现多级联动
- 用Jquery实现多级下拉框无刷新的联动
- 用Jquery实现多级下拉框无刷新的联动
- jquery 实现二级/三级/多级联动菜单的思路及代码
- php ajax实现的二级(多级)联动菜单(2008-10-21,11:36:08)
- jquery学习笔记-jquery实现无刷新联动
- php ajax实现的二级(多级)联动菜单(2008-10-21,11:36:08)
- php ajax实现的二级(多级)联动菜单(2008-10-21,11:36:08)
- JQuery实现省市区三级联动
- Jquery实现城市三级数据联动的实例
- 用ajax实现dropdownlist多级联动实例