Javascript error
Posted: Sun Jun 18, 2006 12:44 am
I'm using this javascript code to count down from 30 minutes. The original code would reset to 30 when it reached 0. I modifed the code to display a link to refresh the page, but when it reaches 0, displays the link, I get an error on the page:
"document.getelementbyID(....) is null or not an object"
Here's the code:
The part I modified in was:
I did look up javascript functions but I'm not at all familiar with javascript references like php. I wish there was a javascript.net like php.net.
"document.getelementbyID(....) is null or not an object"
Here's the code:
Code: Select all
/* the timer */
function StartTimer()
{
setTimeout("UpdateTimer()", 1000);
resetmin=30;
resetsec=0;
if (min < 0) {
min=resetmin;
sec=resetsec;
}
if (sec < 10) {
temp="0";
}
else {
temp="";
}
document.getElementById("idTimer").innerHTML="<span id=\"idMin\" style=\"font-weight: normal; \"><font size='5'>"+min+"</font></span>:<span id=\"idSec\" style=\"font-weight: normal; \"><font size='5'>"+temp+sec+"</font></span>";
}
function UpdateTimer()
{
setTimeout("UpdateTimer()", 1000);
sec--;
if (min == 0 && sec == 0)
{
document.getElementById("idTimer").innerHTML="<a href='javascript:history.go(0)'>refresh</a>";
return;
}
if (sec < 0)
{
sec = 59;
min--;
}
document.getElementById("idMin").innerHTML=min;
var temp;
if (sec < 10) {
temp="0";
}
else {
temp="";
}
temp = temp+sec;
document.getElementById("idSec").innerHTML=temp;
}Code: Select all
document.getElementById("idTimer").innerHTML="<a href='javascript:history.go(0)'>refresh</a>";
return;I did look up javascript functions but I'm not at all familiar with javascript references like php. I wish there was a javascript.net like php.net.