| You are here: DEVPPL ‹ Forum ‹ Programming ‹ Java Forum |
NOTIFICATIONS
|
|
|||||||||||||||
Login |
trying to modify a stop watch script..
1 post
• Page 1 of 1
0
trying to modify a stop watch script..
hello, i want to make a countdown timer, i found a script for one which looks nice but i need to change a couple of things..
when the webpage loads there are two input fields, this is seconds and tenths of seconds..the user can type the required value into these..
but instead of counting down it actually counts up... i want to be able to put in the required values, hit the button and have it count down to 0.
the other thing is, i need it working in hours and mins rather than seconds and tenths of seconds...
im thinking i need to alter the setTimeout values for this, but im really not sure...
would much appreciate any help anyone can give...
thanks..
this is the code:
when the webpage loads there are two input fields, this is seconds and tenths of seconds..the user can type the required value into these..
but instead of counting down it actually counts up... i want to be able to put in the required values, hit the button and have it count down to 0.
the other thing is, i need it working in hours and mins rather than seconds and tenths of seconds...
im thinking i need to alter the setTimeout values for this, but im really not sure...
would much appreciate any help anyone can give...
thanks..
this is the code:
- Code: Select all
var timer1;
var sds =0;
var stop = false;
Count();
function Count()
{
sds = document.countdown.counter.value;
document.countdown.counter.value= parseInt(sds)+1;
document.countdown.countmilli.value= 0;
if(timer1)
{
clearTimeout(timer1);
clearTimeout(timer2);
}
if(stop == false)
{
timer2= setTimeout('CountMilli()', 100);
timer1= setTimeout('Count()', 995);
}
}
function CountMilli()
{
sds = document.countdown.countmilli.value;
document.countdown.countmilli.value= parseInt(sds)+1;
if(timer2)
{
clearTimeout(timer2);
}
if(stop == false)
{
timer2= setTimeout('CountMilli()', 100);
}
}
function stopper()
{
if(timer1)
{
clearTimeout(timer1);
clearTimeout(timer2);
}
stop=true;
}
function starter()
{
if(timer1)
{
clearTimeout(timer1);
clearTimeout(timer2);
}
stop=false;
timer1= setTimeout('Count()', 995);
}
function new1()
{
if(timer1)
{
clearTimeout(timer1);
clearTimeout(timer2);
}
stop=false;
document.countdown.counter.value= 0;
document.countdown.countmilli.value=0;
timer1= setTimeout('Count()', 1000);
timer2= setTimeout('CountMilli()', 100);
}
- Paul
- Reputation: 0
- Posts: 3
- Joined: Sun Jun 20, 2010 8:52 pm
- Highscores: 0
- Arcade winning challenges: 0
trying to modify a stop watch script.. - Sponsored results
- Sponsored results
|
|