html代码:
-
<label for="classify" class="col-sm-2 control-label">填报部门:</label>
-
<div class="col-sm-3">
-
<select class="selectpicker form-control" data-live-search="true" name="addid" id="addid">
-
</select>
-
</div>
JS代码:
-
/*获取下拉菜单*/
-
function showSel(){
-
$.ajax({
-
"type" : 'get',
-
"url": 地址,
-
"dataType" : "json",
-
"success" : function(data) {
-
var depart_list = data.data;
-
var opts = "";
-
for( var depart_index = 0 ; depart_index < depart_list.length; depart_index++ ){
-
var depart = depart_list[depart_index];
-
opts += "<option value='"+需要加的.id+"'>"+显示的名称.name+"</option>";
-
}
-
// 查询界面
-
$("#addid").append(opts);
-
$("#addid").selectpicker("refresh");
-
}
-
});
-
}
这样就可以了