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/
– Douglas Garrido