How to insert counter in table? HTML and Javascript

2

How do I put the countdown timer on the side of each name that is entered into the table? Since the countdown timer must start from 20 mins 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>
    
asked by anonymous 01.12.2016 / 06:28

1 answer

1

Here's the solution to your problem: link

    
01.12.2016 / 17:01