var a = document.getElementById("czas").innerHTML; lub var a = document.getElementById("czas").value;
Ale nie działa :/
var czas = 1000; function odlicz(time){ time -= 1; } setInterval("odliczaj(czas);", 1000);
<html> <head> <META HTTP-EQUIV="content-type" CONTENT="text/html; CHARSET=iso-8859-2"> <script type="text/javascript"> var czas = 6000000; function odliczaj(div, time) { var d, g, m, s; var wd, wg, wm, ws; if(czas > 0){ czas -= 1;} d = Math.floor(time/86400); g = Math.floor((time-(d*86400))/3600); m = Math.floor((time-(d*86400)-(g*3600))/60); s = Math.floor(time-(d*86400)-(g*3600)-(m*60)); if(d < 10){wd = "0"+d}else{wd = d}; if(g < 10){wg = "0"+g}else{wg = g}; if(m < 10){wm = "0"+m}else{wm = m}; if(s < 10){ws = "0"+s}else{ws = s}; document.getElementById(div).innerHTML = "Dni: "+wd+" Godzin: "+wg+" Minuut: " +wm+" Sekund: "+ws; } setInterval("odliczaj('czas');", 1000); </script> </head> <body> </body> </html>