Script Numaratoare inversa

Discutii si intrebari legate de scripturi si functii JavaScript, jQuery si Ajax, cod JavaScript in general.
cosatzy
Mesaje: 1

Script Numaratoare inversa

Salut , imi puteti da si mie un script numaratoare inversa de 10 minute.
"Va rugam asteptati: 10 minute."
Multumesc.

MarPlo Mesaje: 4343
Salut
Incearca sa te descurci cu acest cod:

Cod: Selectaţi tot

Asteptati: &nbsp; <span id="showmns">00</span>:<span id="showscs">00</span>
<script type="text/javascript"><!--
function countdownTimer(mnt, scs) {
  // https://coursesweb.net/javascript/
  // gets data for minutes and seconds
  ctmnts = mnt;
  ctsecs = scs;

  // decrease seconds, and decrease minutes if seconds reach to 0
  ctsecs--;
  if(ctsecs < 0) {
    if(ctmnts > 0) {
      ctsecs = 59;
      ctmnts--;
    }
    else {
      ctsecs = 0;
      ctmnts = 0;
    }
  }

  // display the time in page, and auto-calls this function after 1 seccond
  if(document.getElementById('showmns') && document.getElementById('showscs')) {
    document.getElementById('showmns').innerHTML = ctmnts;
    document.getElementById('showscs').innerHTML = ctsecs;
  }
  if(ctsecs > 0 || ctmnts > 0) setTimeout('countdownTimer('+ ctmnts +', '+ ctsecs +')', 1000);
  else alert('Gata');
}

// strat the countdown (10 minutes, 0 seconds)
countdownTimer(10, 0);
//-->
</script>

Subiecte similare