利用ajax画表格

$(function(){
$('#showList').hide();
var date=new Date;
var year=date.getFullYear(); 
$('#YEAR').append( "<option value=\""+year+"\">"+year+"</option>" );
for(var i=1;i<10;i++){
//var c=Number(year)+Number(i);
var d=Number(year)-Number(i);
//$('#YEAR').append( "<option value=\""+c+"\">"+c+"</option>" );
$('#YEAR').append( "<option value=\""+d+"\">"+d+"</option>" );
}
 /* $('#YEAR').hover(function(){  
 location.reload();
 })  ; */
    $('#YEAR').change(function(){
    $('.mainbg').hide();
    $('#showList').show();
    //年份改变时先将已有数据清0
    //表格行数  
    var rows = document.getElementById("tableList").rows.length;   
    //表格列数 
    var cells = document.getElementById("tableList").rows.item(0).cells.length; 
    for(var m=1;m<=rows;m++){
    for(var n=2;n<=cells;n++){
    $("#tableList").find("tr").eq(m).find("td").eq(n).html("0.0");
    }
    }
    var id= $("#tableList").find("tr").eq(i-1).find("td").eq(0).text();
        $.ajax({
             type: "GET",
             url: "project.do?actionType=queryByYear",
             data:{
            year: this.value ,
            projectClassId:'0'
            },
             dataType: "json",
             success: function(data){
            var html='<table cellSpacing="0" id="table"  cellPadding="0"  align="center" border="0"><TBODY><tr><th width="18%" ><div align="center">总计</div></th><td  width="8%">'+data.nowCountProject+'</td>'+
            '<td width="8%">'+data.feeAuthorize+'</td><td width="8%">'+data.incomeFees+'</td></tr><tr><th  width="18%"><div align="center">去年同期</div></th><td width="8%">'+data.LastCountProject+'</td><td width="8%">'+
            data.LastYearfeeAuthorize+'</td><td width="8%">'+data.LastYearincomeFees+'</td></tr><tr><th width="18%"><div align="center">增长</div></th><td width="8%">'+data.percentageCount+'</td><td width="8%">'+data.percentageAccess+'</td><td width="8%">'+
            data.percentageIncome+'</td></tr></TBODY></table>';
            $('#show').html(html);
             $.each(data.authorizeDataMap, function(key, value){
             for(var i=1;i<30;i++){
            var id= $("#tableList").find("tr").eq(i-1).find("td").eq(0).text();
            if(id==key){
            $("#tableList").find("tr").eq(i-1).find("td").eq(2)
            .html('<a href="project.do?actionType=init&@projectClassId=0&@checkStatusId=2&@projectTypeId='+id+'">'+value[1]+'</a>');
            $("#tableList").find("tr").eq(i-1).find("td").eq(3).html(value[2]);
           
             }
               }); 
             
             $.each(data.incomeDataMap, function(key, value){
             for(var i=1;i<30;i++){
            var id= $("#tableList").find("tr").eq(i-1).find("td").eq(0).text();
            if(id==key){
            $("#tableList").find("tr").eq(i-1).find("td").eq(4)
            .html('<a href="../outlay/outlay.do?actionType=init&@projectClassId=0&@checkStatusId=2&@projectTypeId='+id+'&contract=false">'+value[1]+'</a>');
            }
             }
               }); 
           
                      }
         }); 
    });
});
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值