I'm trying to make a 2 column table cell, with countdown timers on the right side, and titles on the left column, i can only figure out how to do one countdown timer for one cell but i need to have multiple countdown timers for all the cells.
So i can just type a Date in the right side and javascript makes it count down until that date is reached. the only thing i managed to do is a single countdown timer and have an ID it refers too, but i do not know how to make it on several more.
The dates will be different on each column.
heres the javascript code
// Set the date we're counting down to
var countDownDate = new Date("Dec 10, 2020 21:41:25").getTime();
// Update the count down every 1 second
var x = setInterval(function() {
// Get today's date and time
var now = new Date().getTime();
// Find the distance between now and the count down date
var distance = countDownDate - now;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
// Display the result in the element with id="demo"
document.getElementById("demo").innerHTML = days + "d " + hours + "h "
+ minutes + "m " + seconds + "s ";
// If the count down is finished, write some text
if (distance < 0) {
clearInterval(x);
document.getElementById("demo").innerHTML = "DROPPED";
}
}, 1000);
</script>
and heres the html code
<html>
<head>
</head>
<body>
<table style="width:600px">
<tr>
<th>TEXT</th>
<th>COUNTDOWN</th>
</tr>
<tr>
<td><a href="www.google.com">TBA</a></td>
<td id="demo"></td>
</tr>
<tr>
<td><a href="www.google.com">TBA</a></td>
<td>DATE</td>
</tr>
<tr>
<td><a href="www.google.com">TBA</a></td>
<td> DATE </td>
</tr>
<tr>
<td><a href="www.google.com">TBA</a></td>
<td>DATE</td>
</tr>
<tr>
<td><a href="www.google.com">TBA</a></td>
<td>DATE</td>
</tr>
<tr>
<td><a href="www.google.com">TBA</a></td>
<td> DATE</td>
</tr>
</table>
</body>
</html>
Kind regards.