Countdown from a list passing in an if

0

I have an email list from a database, but I just want to send it to those that are marked with checkbox . If I ticked 10, I want it to decrease one, each time I go through the if, and when I pass the numbers, and when I finish displaying a message.

For example: I marked the ten and click on send, it can be in a modal, show the decreasing numbers and then a message like done.

Any ideas or tips are welcome.

    
asked by anonymous 10.08.2015 / 19:28

1 answer

0

You can simply use setInterval to apply the reduction in values according to time and, after finishing, clear the execution:

var emailsToSend = 10;
var counter = document.getElementById("counter");
var interval = setInterval(function() {
  counter.innerHTML = emailsToSend;
  if (emailsToSend === 0) {
    clearInterval(interval);   
  }
  emailsToSend--;
}, 150);

Example: link

    
10.08.2015 / 19:50