It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Java Forum

trying to modify a stop watch script..

trying to modify a stop watch script..

Postby paul609 on Sun Jun 20, 2010 8: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);

}
paul609
 
Posts: 3
Joined: Sun Jun 20, 2010 7:52 pm

Who is online

Users browsing this forum: No registered users and 3 guests