Ive managed to follow instructions from a website to create a countdown timer which is very simular to this one: (https://www.digitalocean.com/community/tutorials/js-building-countdown-timer#prerequisites). What i cant get it to do is automatically reset. ive tried various different ways but to no success. ive got 3 timers on a page all counting down to zero:
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Heya,
you’ll need to add a function to check if the target time has been reached and, if so, reset the timer to its starting value. You can do this by comparing the current time and the target time.
Here’s a basic idea of how to achieve this:
Create a function that will set the target time for each of your countdown timers, then modify your countdown function to call the function when the timer reaches 0, and then call itself again.
Then you can call the countdown function for each of your timers, passing the appropriate timer type (daily, weekly, or monthly)
Hope that this helps!
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.