Skip to content
Advertisement

How to add a Countdown Timer with a value returned from Database using Ajax and displayed within a

Really stuck on this one. I have created an admin panel which retrieves data from MySQL database and displays the results within HTML using a Data table using Ajax/Json. This all works fine. One of the fields that is retrieved is a time which is given by the user in hours and minutes displayed as – 00:00. I need to take this time and make it countdown to zero within the tag. One other thing I should add is the page refreshes every minute as it needs to collect data often.

Can anyone help with this?

Here is the code so far HTML –

JavaScript

And here is my Javascript –

JavaScript

The ${value[‘typea9’]} is the value with the time in it which needs turning into a countdown.

Any help would be much appreciated with this.

Advertisement

Answer

Ok worked it out and here is the code if anyone else is ever stuck with a similar problem –

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement