汇总TD onkeyup

时间:2016-04-17 07:53:57

标签: javascript php jquery mysql ajax

我有一个代码,应该总结列中的所有td。但问题是,总和不会自动更新onkeyup,

这是代码

library(lubridate)
library(data.table)
res <- setDT(ts1)[,{st <- dmy_hm(start)
                    et <- dmy_hm(end)
                    c(tstrsplit(format(head(seq(st, et, by = "1 hour"),-1),
                          "%d/%m/%Y %H:%M"), "\\s+"), as.character(value))} ,
        by =  .(rn=1:nrow(ts1))
   ][, rn := NULL][]
setnames(res, c("date", "hour", "value"))[]
#          date  hour       value
# 1: 26/11/2014 13:00  decreasing
# 2: 26/11/2014 14:00  decreasing
# 3: 26/11/2014 15:00  decreasing
# 4: 26/11/2014 16:00  decreasing
# 5: 26/11/2014 17:00  decreasing
# 6: 26/11/2014 18:00  decreasing
# 7: 26/11/2014 19:00  decreasing
# 8: 26/11/2014 20:00 increasing 
# 9: 26/11/2014 21:00 increasing 
#10: 26/11/2014 22:00 increasing 
#11: 26/11/2014 23:00 increasing 
#12: 27/11/2014 00:00 increasing 
#13: 27/11/2014 01:00 increasing 
#14: 27/11/2014 02:00 increasing 
#15: 27/11/2014 03:00 increasing 
#16: 27/11/2014 04:00 increasing 
#17: 27/11/2014 05:00 increasing 
#18: 27/11/2014 06:00 increasing 
#19: 27/11/2014 07:00 increasing 
#20: 27/11/2014 08:00 increasing 

我不知道这个问题是什么,一切似乎都没问题。请帮助我,。,

1 个答案:

答案 0 :(得分:2)

您是否尝试使用类型转换,这可能是个问题。

听说我们没有和数组,所以它不需要获得关键,值,而不是itratting .each

只需简单地获取内部html,如价值低于

 function processCurr(param){    
    var inputcurr= $('#inputCurr'+param).val();
    var conversion = $('#convRate'+param).val();
    $('#calculatedCurr'+param).html(inputcurr * conversion);
    calculateSum();
}

function calculateSum(){
    var sum = parseFloat(0);
    $(".calculatedCurr").each(function(){
        //Hear we dont have and array so it's not required to get key, value while itratting .each
        // just simply get inner html like bellow as value
        $val=parseFloat($(this).html());
        if (!isNaN($val) && $val.length != 0) {
            sum =sum + parseFloat($val);
            $(this).css("background-color", "#FEFFB0");
        }
        else if ($val.length != 0){
            $(this).css("background-color", "blue");
        }

    });

    $("#totalSumPayment").html(sum);
}