六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 30|回复: 0

下拉框绑定

[复制链接]

升级  11.33%

15

主题

15

主题

15

主题

秀才

Rank: 2

积分
67
 楼主| 发表于 2013-1-23 01:46:35 | 显示全部楼层 |阅读模式
// 查询取值   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);              }          });      });
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

快速回复 返回顶部 返回列表