Countdown does not work with 2 or more records, only with one

0

I have a back account generated in javascript and it is shown in datatables. The issue is that it works only when it is one record per line, but when it is 2 or more, it simply does not show the account back. The console shows no errors of any kind. The records coming from the BD are correct and there is no problem with them. The function that generates the countdown is as follows:

function faltan() {

    var actualiza = 1000;
    var ahora = new Date();
    var faltan = futuro - ahora;

    if (faltan > 0) {
        var segundos = Math.round(faltan / 1000);
        var minutos = Math.floor(segundos / 60);
        var segundos_s = segundos % 60;
        var horas = Math.floor(minutos / 60);
        var minutos_s = minutos % 60;
        var dias = Math.floor(horas / 24);
        var horas_s = horas % 24;

        (segundos_s < 10) ? segundos_s = "0" + segundos_s : segundos_s = segundos_s;
        (minutos_s < 10) ? minutos_s = "0" + minutos_s : minutos_s = minutos_s;
        (horas_s < 10) ? horas_s = "0" + horas_s : horas_s = horas_s;
        (dias < 10) ? dias = "0" + dias : dias = dias;
        var resultado = dias+ ":" + horas_s + ":" + minutos_s + ":" + segundos_s;
        document.getElementById("text").value = resultado;
        setTimeout("faltan()", actualiza);
    }
    else {
        document.getElementById("text").value = "Tiempo Expirado";
    }
}

the table generated by datatables is as follows:

{
 "sClass": "alignRight",
 "data" : null,
 'render': function (data, type, row, meta) {
          var tiempo = row['tiempo'];
          var splitDate= tiempo.split(" ");
          var date=splitDate[0].split("-");
          var time=splitDate[1].split(":");

          var dd=date[2];
          var mm=date[1]-1;
          var yyyy =date[0];
          var hh=time[0];
          var min=time[1];
          var ss=time[2];

          window.futuro = new Date(yyyy, mm, dd, hh, min);
          return '<input id="text" readonly cols="8" style="resize:none">';
        }
    }

It should be noted that the future variable is a global variable. I leave an image as a reference for the problem. I appreciate any help or guidance in this regard. Greetings to all.

    
asked by maha1982 16.08.2018 в 05:35
source

0 answers