script> //timer //Copyright by Ewelinka :) //http://www.webtips.pl/post20378.html //Please do not remove this information :) var secs = 0; //**** liczba sekund do odliczenia var element = 'czas'; //**** atrybut "id" elementu wyświetlającego wynik var T = null; function count(id){ temp = secs; if(secs > 0){ //**** ten kawałek kodu "rozbija" sekundy na inne jednostki result = Math.floor(temp / 86400) + ' dni '; temp %= 86400; result += Math.floor(temp / 3600) + ' godzin '; temp %= 3600; result += Math.floor(temp / 60) + ' minut '; temp %= 60; result += temp + ' sekund'; document.getElementById(element).innerHTML = result; //**** wypisanie stanu zegara secs--; }else{ alert('Już czas!:)'); //**** co robimy gdy odliczanie się zakończy clearInterval(T); } } function counter(days, hours, minutes, seconds){ secs = days*86400 + hours*3600 + minutes*60 + seconds; T = window.setInterval("count()", 1000); //count(); }
Rejestracja