How to insert countdown into table? HTML and Javascript

Asked

Viewed 434 times

2

How do I place the countdown counter next to each name that is inserted into the table? Where the countdown must start from 20 min to each name entered

<head>


<script type="text/javascript">
function startTimer(duration, display) {
var timer = duration, minutes, seconds;
setInterval(function () {
    minutes = parseInt(timer / 60, 10); 
    seconds = parseInt(timer % 60, 10);

    minutes = minutes < 10 ? "0" + minutes : minutes;
    seconds = seconds < 10 ? "0" + seconds : seconds;

    display.textContent = minutes + ":" + seconds;

    if (--timer < 0) {
        timer = 0;
    }

}, 1000);
}

window.onload = function () {
var fiveMinutes = 60 * 20,
display = document.querySelector('#time');
startTimer(fiveMinutes, display);
};



var d = document;
function processar(idTabela){

 var newRow = d.createElement('tr');
 newRow.insertCell(0).innerHTML = d.getElementsByName('user')[0].value;
 newRow.insertCell(1).appendChild(time);
 d.getElementById(idTabela).appendChild(newRow);
 return false;
}
</script>
</head>

<body>
<br>

<font size="6">  
<table border='1' width='250' height='250' > 


<tbody id="myTable"> </tbody></font>

<font size="4" >Nome:   <input type="text" name="user" >


<input type="submit" value="Confirmar"> 

<div id="time"></div>

</font>

</form>

</body>
  • Check out this plugin: https://inorganik.github.io/countUp.js/

1 answer

1


  • YOU ARE A GENIUS <3

  • Friend, you know how to export this table to excel ? Or save it in some corner?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.