Answers for "submit form when countdown goes to zero"

1

submit form when countdown goes to zero

function Update() {
    var id = 'demo'; // Display ID for time left 'demo'
    var countDownDate = new Date('Dec 3, 2020 15:34:00').getTime();
    var now = new Date().getTime();
    var distance = countDownDate - now;
    if (distance > 0) {
      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);

      if (distance < 0) {
        document.write("Time-up");
      } else {
        document.getElementById(id).innerHTML = (hours + "h " + minutes + "m " + seconds + "s ");
      }
      window.setTimeout('Update()', 1000);
    } else {
      document.getElementById(id).innerHTML = ("Form is submitting");
      $('.username').submit(); // Form to submit but add action="actionpage.php"
    }
  }
  Update();
Posted by: Guest on December-03-2020

Code answers related to "submit form when countdown goes to zero"

Code answers related to "Javascript"

Browse Popular Code Answers by Language