You are here: DEVPPL Forum Programming Java Forum
NOTIFICATIONS
54.107
MEMBERS
15.696
TOPICS
62.284
POSTS
  562
FLASH GAMES
7.740
TUTORIALS
 

Login

E-mail:
Password:

trying to modify a stop watch script..

0

Loading

trying to modify a stop watch script..

Postby Paul » Sun Jun 20, 2010 9:10 pm

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:
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

Login to get rid of ads

 

^ Back to Top