<html> <head> <script type="text/javascript"> var seconds = 0; var minutes = 0; var hours = 0; function zeroPad(time) { var numZeropad = time + ''; while(numZeropad.length < 2) { numZeropad = "0" + numZeropad; } return numZeropad; } function countSecs(gdzie) { seconds++; if (seconds > 59) { minutes++; seconds = 0; } if (minutes > 59) { hours++; minutes = 0; seconds = 0; } } function startTimer(a) { action = window.setInterval("countSecs('"+a+"');",1000); } </script> </head> <body onload="startTimer('timeBox');"> </body> </html>
Próbowałem w ten sposób, głownie chodzi mi o to by ten skrypt liczył czas od podanych wartości wczytanych w pętli while z mysql i wyświelał dla każdego rekordu czas w <td id='tutaj'></td>
Czułbym się niezmiernie usatysfakcjonowany jeżeli znalazłby się ktoś kto podpowie mi dlaczego timer wykonuje 1 interval i staje w miejscu ?
o to jak próbowałem:
<html> <head> <script type="text/javascript"> function zeroPad(time) { var numZeropad = time + ''; while(numZeropad.length < 2) { numZeropad = "0" + numZeropad; } return numZeropad; } function countSecs(gdzie,hours,minutes,seconds) { seconds++; if (seconds > 59) { minutes++; seconds = 0; } if (minutes > 59) { hours++; minutes = 0; seconds = 0; } } function startTimer(a,h,m,s) { action = window.setInterval("countSecs('"+a+"','"+h+"','"+m+"','"+s+"');",1000); } </script> </head> <body onload="startTimer('timeBox','0','0','0');"> </body> </html>