// 查询取值
public void getcbBoxValues(){
List<Category> list;
Category category = new Category();
category.setFatherId(35);
list = manager.getByEntity(category);
Struts2Utils.renderJson(list);
}
//页面列表页搜索绑定
$(document).ready(function(){
$.ajax({
url: "category!getcbBoxValues.action",
type: "post",
contentType: "application/json;charset=utf-8",
dataType: "json",
data: "categoryId = 35",
success: function(json) {
var str="";
$.each(json,function(i){
str += "<option value=\""+json[i].id+"\">" + json[i].name + "</option>";
});
str+="";
$("#categoryId").html(str);
},
error: function(e) {
alert(e.responseText);
}
});
});
//页面列表查询绑定
$(document).ready(function(){
$.ajax({
url: "category!getcbBoxValues.action",
type: "post",
contentType: "application/json;charset=utf-8",
dataType: "json",
data: "categoryId = 35",
success: function(json,e) {
var info1 = document.getElementById("xiaoShuoType");
$.each(json,function(i,e){
info1.options.add(new Option(e.name,e.id));
});
for(var j=0;j<info1.length;j++){
var info2=info1[j].value+"";
if(info2=="${model.categoryId}"){
info1.selectedIndex=j;
break;
}
}
},
error: function(e) {
alert(e.responseText);
}
});
});
下拉框绑定
最新推荐文章于 2024-11-08 11:17:16 发布