troubleshooting Question

total time

Avatar of stargateatlantis
stargateatlantis asked on
3 Comments1 Solution264 ViewsLast Modified:
I have the following code here  I was wondering how would i have a label that would calculate the total time of all the timers running.  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src=""></script>
<script language="javascript">
$(document).ready(function () {
	$("#btn1Start").click(function () {
		timer1 = setInterval("$.do_time('timer1')", 1000);
		$(this).attr("disabled", true);
	$("#btn2Start").click(function () {
		timer2 = setInterval("$.do_time('timer2')", 1000);
		$(this).attr("disabled", true);
	$("#btn3Start").click(function () {
		timer3 = setInterval("$.do_time('timer3')", 1000);
		$(this).attr("disabled", true);
//Timer JQuery function
(function ($) {
	$.do_time = function(timerID) {
		var time = ($("#" + timerID).html()).split(':');
		var hour = parseInt(time[0], 10);
		var minute = parseInt(time[1], 10);
		var second = parseInt(time[2], 10) + 1;
		if (second > 59) {
			second = 0;
		if (minute > 59) {
			minute = 0;
		$("#" + timerID).html((hour>9?hour:'0'+hour) +':'+ (minute>9?minute:'0'+minute) +':'+ (second>9?second:'0'+second));
	} //End Doo time function
<table width="160">
      <td id="timer1">00:00:00</td>
      <td><input type="button" id="btn1Start" value="button1" /></td>
      <td id="timer2">00:00:00</td>
      <td><input type="button" id="btn2Start" value="button2" /></td>
      <td id="timer3">00:00:00</td>
      <td><input type="button" id="btn3Start" value="button3" /></td>
Samuel Liew

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros