how can implement a multiple stop watch in a php site for displaying different time consume by the technicians to resolve the problem.
in my site there are work assign for completion to technician where i want to know about how much time taken by the technician in solving the problem.i implement a simple stop watch with the help of java script and is working untill when we stay on page but when we go another page then it is stopped.
and next problem is that when i try it to multiple stopwatch implement in the same page then only one is working.
sorry for gramitical error becoz my english is week.
the code is here
var swCycleTime=50;
var sw,swObj,swct,swnow,swcycle;
var swObjAry=new Array();
function swStart(id,ud){
swObj=document.getElementById(id);
swct=swObj.innerHTML.split(':');
swnow=new Date();
swObj.now=swnow.getTime();
swObj.reset=swObj.innerHTML;
swObj.ud=ud;
if (!isNaN(swObj.innerHTML)){
swObj.time=parseInt(swObj.innerHTML);
}
else if (swct.length==4){
swObj.time=(swct[0]*1000*60)+(swct[1]*1000*60)+(swct[2]*1000)+parseInt(swct[3]);
}
else if (swct.length==3){
swObj.time=(swct[0]*1000*60)+(swct[1]*1000)+parseInt(swct[2]);
}
else if (swct.length==2){
swObj.time=(swct[0]*1000)+parseInt(swct[1]);
}
else if (swct.length==1){
swObj.time=parseInt(swct[1]);
}
if (!swObj.time){
swObj.time=1;
}
if (!swObj.c){
swObj.c=ud;
swObjAry[swObjAry.length]=swObj;
}
}
function swStop(id){
swObj=document.getElementById(id);
if (!swObj.time){ return; }
swObj.time=null;
sw=new Date().getTime();
swObj.cycle+=(sw-swcycle);
if (swObj.ud=='-'){
swObj.cycle-=(sw-swcycle);
if (swObj.cycle<0){ swObj.cycle=0; }
}
swObj.innerHTML=(parseInt(swObj.cycle/1000/60/60)%60)+':'+(parseInt(swObj.cycle/1000/60)%60)+':'+((parseInt((swObj.cycle)/1000)%60)+':'+(swObj.cycle%1000));
}
function swCycle(){
swcycle=new Date().getTime();
for (sw0=0;sw0<swobjary.length;sw0++){>
if (swObjAry[sw0].time){
swObjAry[sw0].cycle=swObjAry[sw0].time+(swcycle-swObjAry[sw0].now);
if (swObjAry[sw0].ud=='-'){
swObjAry[sw0].cycle=swObjAry[sw0].time-(swcycle-swObjAry[sw0].now);
if (swObjAry[sw0].cycle<0){ swObjAry[sw0].cycle=0; swObjAry[sw0].time=0; }
}
swObjAry[sw0].innerHTML=(parseInt(swObjAry[sw0].cycle/1000/60/60)%60)+':'+(parseInt(swObjAry[sw0].cycle/1000/60)%60)+':'+((parseInt((swObjAry[sw0].cycle)/1000)%60)+':'+(swObjAry[sw0].cycle%1000));
}
}
}
function swReset(id,dt){
swObj=document.getElementById(id);
swObj.innerHTML=swObj.reset;
swObj.time=null;
}
setInterval('swCycle()',swCycleTime);
<input type="button" value="Start" önclick="swStart('beg2','+');">
<input type="button" value="Stop" önclick="swStop('beg2');">
<input type="button" value="Reset" önclick="swReset('beg2');">
<div id="beg2">0:00:00:000</div>