I would like to be able to make users choose how many minutes the timer should countdown for, what should I change/add to this script? BTW I have no prior experience in Javascript and I'm learning right now, so please keep that in mind! Any help is MUCH appreciated. This is a timer that should count down minutes, this is the design I have done in html and css:
I want the users to enter a "work time" and a "break time" so that the timer counts down the work time and when thats done it automatically counts down the break time and repeat. As i said earlier this is my first "js project" so any help is much needed and appreciated!
var countDownDate = new Date("Oct 16, 2021 20:37:25").getTime();
var x = setInterval(function() {
var now = new Date().getTime();
var distance = countDownDate - now;
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);
document.getElementById("demo").innerHTML = minutes + "m " + seconds + "s ";
}
}, 1000);
</script>
Here is the HTML form to select minutes:
<div class="formsss"><form action="."> <input type="number" value="1" class="TaskTime"/>Work Minutes</> <input type="number" value="1" class="BreakTime"/>Break Minutes</> <button type="submit" class="submitt">Save</button>