javascript timer that counts up hours:minutes:seconds

Hello experts I am trying to create a timer that will count up in hours minutes seconds.  
In this format 00:00:00.  I have 3 labels with ids lblsecond, lblminute, lblhour.  I cant seem to get this to work.

I have a timer that fires when the page loads and I make use of ajax to call serverside code and connect to a database.  That part you dont have to worry about because it works.  The function ServerSideAdd is a server function that connects to the database.  What I want to do is monitor the value that ServerSideAdd retrieves and if its equal to 1 start another timer that increments the seconds and minutes and so on.  How can I make this work?  Below i have some code which retrieves the value every second to see if it has changed.  The code below doesnt work but it gives you an idea of what I need, can someone modify this to work?

<script language = javascript>
var el=10
var sec=1
var min=0
var hour=0
var times = ServerSideAdd();
function starttimer(){
el--  
if (el>=0){
     setTimeout("starttimer()",1000)
     times = ServerSideAdd();
    if (times==1){
   sec ++
      document.getElementById('lblsecond').innerHTML = sec;
      if (sec == 60){
         sec = 0
         min ++
         document.getElementById('lblminute').innerHTML = min;
       }
     if (min==60){
      min = 0
      hour ++
      document.getElementById('lblhour').innerHTML = hour;
     }
   }
   else{
   document.getElementById('lblsecond').innerHTML = 00;
   document.getElementById('lblminute').innerHTML = 00;
   document.getElementById('lblhour').innerHTML = 00;
   }
  }
else{
     el=10;
     starttimer();
     }
}

</script>


      </HEAD>
      <body onload="starttimer();">
tentavariousAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

callrsCommented:
Try this demo:
<script language = javascript>
var el=10
var sec=1
var min=0
var hour=0

var times=Math.floor(Math.random()*10);

function starttimer(){
el--  
if (el>=0){
      setTimeout("starttimer()",1000)
      times=Math.floor(Math.random()*10);
      if (times!=1){
            sec ++
            document.getElementById('lblsecond').innerHTML = sec;
            if (sec == 60){
                  sec = 0
                  min ++
                  document.getElementById('lblminute').innerHTML = min;
                  }
            if (min==60){
                  min = 0
                  hour ++
                  document.getElementById('lblhour').innerHTML = hour;
                  }
            }
      else{
            document.getElementById('lblsecond').innerHTML = 00;
            document.getElementById('lblminute').innerHTML = 00;
            document.getElementById('lblhour').innerHTML = 00;
            }
      }
else{
     el=10;
     starttimer();
     }
}

</script>

     </HEAD>
     <body onload="starttimer();">

<div id="lblhour">
</div>
<div id="lblminute">
</div>
<div id="lblsecond">
</div>
callrsCommented:
<script language = javascript>
var el=10
var sec=-1
var min=0
var hour=0
var Sec="00", Min="00", Hour="00"
var times=Math.floor(Math.random()*10);

function starttimer(){
el--  
if (el>=0){
      setTimeout("starttimer()",1000)
      times=Math.floor(Math.random()*10);
      if (times!=1){
            sec ++
            Sec= sec<10 ? "0"+sec : sec
            if (sec == 60){
                  sec = 0
                  min ++
                  Min= min<10 ? "0"+min : min
                  }
            if (min==60){
                  min = 0
                  hour ++
                  Hour= hour<10 ? "0"+hour : hour
                  }
            document.getElementById('Time').innerHTML = Hour+":"+Min+":"+Sec
            }
      else{
            document.getElementById('Time').innerHTML = "00:00:00"
            min=0; hour=0; sec=0; Sec="00"; Min="00"; Hour="00"
            }
      }
else{
     el=10;
     starttimer();
     }
}

</script>

     </HEAD>
     <body onload="starttimer();">

<div id="Time">

</div>

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.