Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*This Javascript counts down the timer to the zero
- * and release the wanted String after timer is zero. */
- function generoi() {
- var month = document.getElementById('monthValue').value;
- var year = document.getElementById('yearValue').value
- var day = document.getElementById('dayValue').value;
- laskuri(day, month, year);
- //document.getElementById("generated").innerHTML = "Hello World!," +day +"." +month +"." +year;
- }
- function laskuri(day, month, year) {
- var mjono = ""
- // Set the date we're counting down to
- var ajankohta = "" +month +" "+day +", " +year +" 00:00:00";
- var countDownDate = new Date(ajankohta).getTime();
- // Update the count down every 1 second
- var x = setInterval(function() {
- // Get todays 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="generated"
- document.getElementById("generated").innerHTML = days + "d " + hours + "h "
- + minutes + "m " + seconds + "s aikaa jäljellä!";
- // If the count down is finished, write some text
- if (distance < 0) {
- clearInterval(x);
- //Aika täyttyi täytyy korvata viestillä, joka halutaan näyttää, kun laskuri on nollassa.
- document.getElementById("generated").innerHTML = "Aika täyttyi!";
- }
- }, 1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment