Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [javascript] powtarzana funkcja, nie dziala :(
zeroszumu
post
Post #1





Grupa: Zarejestrowani
Postów: 13
Pomógł: 0
Dołączył: 5.11.2011

Ostrzeżenie: (0%)
-----


Witam, mam taki problem, mam funkcję "counter", ktora odlicza mi czas, jest tylko problem, gdy użyje funkcji 2x, to nie dziala.

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html>
  3. <head>
  4. <title>Przekierowanie</title>
  5. <script type="text/javascript">
  6. var secs = 0; //**** liczba sekund do odliczenia
  7. var element = 'czas'; //**** atrybut "id" elementu wyświetlającego wynik
  8. var T = null;
  9. function count(id){
  10. temp = secs;
  11.  
  12. if(secs > 0){
  13.  
  14. //**** ten kawałek kodu "rozbija" sekundy na inne jednostki
  15.  
  16. result = Math.floor(temp / 86400) + ' dni ';
  17. temp %= 86400;
  18. result += Math.floor(temp / 3600) + ' godzin ';
  19. temp %= 3600;
  20. result += Math.floor(temp / 60) + ' minut ';
  21. temp %= 60;
  22. result += temp + ' sekund';
  23. document.getElementById(element).innerHTML = result; //**** wypisanie stanu zegara
  24.  
  25. secs--;
  26. }else{
  27. document.location="http://google.pl"
  28. clearInterval(T);
  29. }
  30.  
  31. }
  32. function counter(days, hours, minutes, seconds){
  33.  
  34. secs = days*86400 + hours*3600 + minutes*60 + seconds;
  35.  
  36. T = window.setInterval("count()", 1000);
  37. //count();
  38. }
  39.  
  40.  
  41. </script>
  42. </head>
  43. <body>
  44. <div id="czas"></div>
  45. <script type="text/javascript">counter(0,0,0,8);</script>
  46. <script type="text/javascript">counter(0,0,0,16);</script>
  47. </body>
  48. </html>
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 18.10.2025 - 06:39