Hi everyone.
I am trying to implement a countdown timer which is displayed on my page. The counter needs to countdown from 10 seconds to 0 upon the page loading up.
I tried the following, but am running into difficulties.
[CODE=javascript]//Some other script here^^^^
var counterForm = document.create Element("form") ;
counterForm.nam e = "form";
counterForm.act ion = "";
var para5 = document.create Element("p");
var counterInput = document.create Element("input" );
counterInput.ty pe = "text";
counterInput.na me = "abc";
counterInput.id = "abc";
counterInput.va lue = '';
counterForm.app endChild(counte rInput);
para5.appendChi ld(counterForm) ;
document.body.a ppendChild(para 5);
} //closes this function
var milisec=0 //simple variables
var seconds=10
function display(){
if (milisec<=0){
milisec=9
seconds-=1
}
if (seconds<=-1){
milisec=0
seconds+=1
}
else {
milisec-=1
document.counte rInput.value=se conds+"."+milis ec
setTimeout("dis play()",100)
}
[/CODE]
The first part of the code is I snippet of function start() which is called as follows:
[HTML]<body onload="start() ">
</body>[/HTML]
The error I’m being given is “counterInput is not defined”.
I had this script working as a separate page, but when I tried adding into my work, the problems started.
Any suggestions?
I am trying to implement a countdown timer which is displayed on my page. The counter needs to countdown from 10 seconds to 0 upon the page loading up.
I tried the following, but am running into difficulties.
[CODE=javascript]//Some other script here^^^^
var counterForm = document.create Element("form") ;
counterForm.nam e = "form";
counterForm.act ion = "";
var para5 = document.create Element("p");
var counterInput = document.create Element("input" );
counterInput.ty pe = "text";
counterInput.na me = "abc";
counterInput.id = "abc";
counterInput.va lue = '';
counterForm.app endChild(counte rInput);
para5.appendChi ld(counterForm) ;
document.body.a ppendChild(para 5);
} //closes this function
var milisec=0 //simple variables
var seconds=10
function display(){
if (milisec<=0){
milisec=9
seconds-=1
}
if (seconds<=-1){
milisec=0
seconds+=1
}
else {
milisec-=1
document.counte rInput.value=se conds+"."+milis ec
setTimeout("dis play()",100)
}
[/CODE]
The first part of the code is I snippet of function start() which is called as follows:
[HTML]<body onload="start() ">
</body>[/HTML]
The error I’m being given is “counterInput is not defined”.
I had this script working as a separate page, but when I tried adding into my work, the problems started.
Any suggestions?
Comment