layui里面的:
查询条件的下拉框:
//加载查询条件的下拉框
$.get("/department/loadAllDepartment", function(data) {
let depId = $("#depId");
let html = '<option value="">请选择所属部门</option>'
$.each(data.data, function(i, item) {
html += '<option value="' + item.id + '">' + item.name + '</option>'
});
depId.html(html);
form.render();
});
数据回显的下拉框:
$.get("/department/loadAllDepartment", function(data) {
let department = $("#department");
let html = '<option value="">所属科室</option>'
$.each(data.data, function(i, item) {
if (item.id == obj.data.depId) {
html += '<option value="' + item.id + '" selected=selected>' + item.name + '</option>'
} else {
html += '<option value="' + item.id + '">' + item.name + '</option>'
}
});
department.html(html);
})
easyUI里面的:
$.ajax({
url: "",
type: "post",
dataType: "json",
success: function(json) {
var txt2 = "<option value='' selected='selected' >全部</option>";
for (var i = 0; i < json.rtData.length; i++) {
txt2 += "<option value='" + json.rtData[i][0] + "' >" + json.rtData[i][1] + "</option>";
}
$("#organizationId").html(txt2);
},
error: function() {}
});
select动态加载最近5年的年份:
function initYear() {
var options = "";
var myDate = new Date();
var startYear = myDate.getFullYear(); // 起始年份
var endYear = myDate.getFullYear() - 4; // 结束年份
options += '<option value="">全部 </option>';
for (var i = startYear; i >= endYear; i--) {
options += '<option >' + i + '</option>';
}
$("#businessYear").html(options);
}