select 联动 JSON jquery
2013-12-12 18:29
495 查看
<td width="40%">
<select name="parentId" id="parentId" style="width:100px;">
<option value="">
--请选择--
</option>
</select>
<select name="companiesSection" id="companiesSection">
<option value="">
--请选择--
</option>
</select>
<script type="text/javascript">
function initParentId() {
var option1 = '';
$.getJSON("${cxp}/manager/dictionary/listDictionary.do?method=getDictionarysByParentId&id=2111",
function(jsonData) {
$.each(jsonData,
function(index, indexItems) {
option1 += "<option value=" + indexItems.id + ">" + indexItems.name + "</option>";
});
$("#parentId").append(option1);
$("#parentId").bind("change",
function() {
selectCompaniesSection($(this).val());
})
})
}
function selectCompaniesSection(id) {
$.ajax({
type: "get",
url: "${cxp}/manager/dictionary/listDictionary.do?method=getDictionarysByParentId",
data: "id=" + id ,
success: function(result) {
$("#companiesSection").empty();
result = eval(result);
if(result.length==0){
$("#companiesSection").append("<option value=''>--请选择--</option");
}else{
for (var i = 0; i < result.length; i++) {
$("#companiesSection").append("<option value='" + result[i].describe + "'>" + result[i].name + "</option");
}
}
}
})
}
initParentId();
</script>
</td>
<select name="parentId" id="parentId" style="width:100px;">
<option value="">
--请选择--
</option>
</select>
<select name="companiesSection" id="companiesSection">
<option value="">
--请选择--
</option>
</select>
<script type="text/javascript">
function initParentId() {
var option1 = '';
$.getJSON("${cxp}/manager/dictionary/listDictionary.do?method=getDictionarysByParentId&id=2111",
function(jsonData) {
$.each(jsonData,
function(index, indexItems) {
option1 += "<option value=" + indexItems.id + ">" + indexItems.name + "</option>";
});
$("#parentId").append(option1);
$("#parentId").bind("change",
function() {
selectCompaniesSection($(this).val());
})
})
}
function selectCompaniesSection(id) {
$.ajax({
type: "get",
url: "${cxp}/manager/dictionary/listDictionary.do?method=getDictionarysByParentId",
data: "id=" + id ,
success: function(result) {
$("#companiesSection").empty();
result = eval(result);
if(result.length==0){
$("#companiesSection").append("<option value=''>--请选择--</option");
}else{
for (var i = 0; i < result.length; i++) {
$("#companiesSection").append("<option value='" + result[i].describe + "'>" + result[i].name + "</option");
}
}
}
})
}
initParentId();
</script>
</td>
相关文章推荐
- Jquery select 三级联动 (需要JSON数据)
- jquery.cityselect.js基于jQuery+JSON的省市或自定义联动效果
- jquery.cityselect.js基于jQuery+JSON的省市-自定义联动效果
- Jquery 解析返回的Json,然后写入select下拉框
- jquery通过struts2请求,返回json数据,在jsp页面形成二级联动下拉列表
- 省市区三级联动[JSON+Jquery]
- JSON+Jquery省市区三级联动
- jQuery JSON实现无刷新三级联动实例探讨
- jQuery 绑定 select 联动 手动触发
- 使用JQUERY实现JSON数据三级联动
- 用jquery写的json省市县三级联动下拉
- jquery实现下拉菜单的二级联动,利用json对象从DB取值显示联动
- JS+JSON 省市区 三级联动 SELECT
- jquery对select进行种各种操作的方法[联动、根据值或文本选中指定的select等]
- jQuery读取json文件,实现省市区/县(国标)三级联动
- 用jquery解析JSON数据的方法 --多级联动。
- 自制的操作下拉列表框(SELECT)的三个jquery插件(ajax填充、联动、增加选项)
- jquery select操作的日期联动实现代码
- 基于jquery & json的省市区联动
- jquery插件-cityselect.js扩展(支持4层联动)