$("#Query").click(function(){
$("#redFlag").html("");
var termCode = $("#term").val();
var termName = $("#term").text();
var week = $("#week option:selected").val();
var weekTimes = $("#week").find("option:selected").attr("child");
$.ajax({
url:"/nm/nm_getRedFlag.action",
type:"POST",
dataType:"json",
data:{"termCode":termCode,"week":week,"weekTimes":weekTimes},
success:function(data){
$("#redFlag").append("<table id = 'red' class = 'report' style='width:100%' border = '0' act = '1' ></table>");
$("#red").append('<caption style="font-size :25px;font-weight:bold;">红领巾 “一日常规”检查公示情况 (第'+weekTimes+'周)</caption><br>');
$("#red").append('<tr><td>班级</td><td>教师卫生</td><td>大课间操</td><td>眼保间操(上午)</td><td>午间活动</td><td>桌椅摆放</td><td>红领巾佩戴</td><td>眼保健操(下午)</td><td>放学(班级情况)</td><td>总分</td><td>颁布小红旗</td></tr>');
if(data != null && data.length != 0){
$.each(data,function(i,item){
$("#red").append('<tr><td>'+item.className+'</td><td>'+item.JSWS+'</td><td>'+item.DKJC+'</td>'
+'<td>'+item.YBJCS+'</td><td>'+item.WJHD+'</td>'
+'<td>'+item.ZYBF+'</td><td>'+item.HLJPD+'</td><td>'+item.YBJCX+'</td><td>'+item.FX+'</td>'
+'<td>'+item.allScore+'</td><td>'+item.flag+'</td></tr>');
});
}
//遍历最后一列所有
var trs = $('#red tr');
$.each(trs,function(){
var td = $(this).find('td:last');
if(td.text() == "1"){
td.html('<img src = "<%=request.getContextPath()%>/JE/resource/redFlag/redFlag.png" width="25px" height="25px" class="giveFlag" />')
}else if(td.text() == "0"){
td.html('<img src = "<%=request.getContextPath()%>/JE/resource/redFlag/grayFlag.png" width="25px" height="25px" class="giveFlag" />')
}
})
},
error:function(){
alert("查询出错,请联系管理员")
}
});
});
js/jQuery 动态创建表格
最新推荐文章于 2022-03-23 17:41:25 发布