ASP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingASP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old June 17th, 2004, 04:14 AM
sanjanah_verma sanjanah_verma is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 190 sanjanah_verma User rank is Corporal (100 - 500 Reputation Level)sanjanah_verma User rank is Corporal (100 - 500 Reputation Level)sanjanah_verma User rank is Corporal (100 - 500 Reputation Level)sanjanah_verma User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 7 h 16 m 13 sec
Reputation Power: 6
Timer/Stop Watch

Hi,
I require a program that will allow a user to start the timer when he hits a button and stop the timer when he hits another button.
And,
Is there anyway where i can get the difference in Time:

Start time=12:15:54
Stop Time=12:20:12

Difference in time is:00:04:18

Any help would be appreciated.

Thanks.

Reply With Quote
  #2  
Old June 17th, 2004, 04:34 AM
manib_108 manib_108 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 20 manib_108 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
u can use javascript for the pupose. on the click of the start button call a javascript function that creates a date type object in javascript and set it to the current system time. u can know about all the functions of date object at the following link:

http://www.devguru.com/Technologies...ckref/date.html

on the click of stop button retrieve the value of that object and subtract it from system time. u will get the difference. hope this will solve ur problem.

Reply With Quote
  #3  
Old June 17th, 2004, 04:54 AM
sanjanah_verma sanjanah_verma is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 190 sanjanah_verma User rank is Corporal (100 - 500 Reputation Level)sanjanah_verma User rank is Corporal (100 - 500 Reputation Level)sanjanah_verma User rank is Corporal (100 - 500 Reputation Level)sanjanah_verma User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 7 h 16 m 13 sec
Reputation Power: 6
I have done by using JavaScript only!But i want to know the exact function/command that is used to find the difference between times.

Reply With Quote
  #4  
Old June 17th, 2004, 06:54 AM
manib_108 manib_108 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 20 manib_108 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
can u give the code u have created so i can see it and tell u the method to be used to get the difference

Reply With Quote
  #5  
Old June 18th, 2004, 01:46 AM
sanjanah_verma sanjanah_verma is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 190 sanjanah_verma User rank is Corporal (100 - 500 Reputation Level)sanjanah_verma User rank is Corporal (100 - 500 Reputation Level)sanjanah_verma User rank is Corporal (100 - 500 Reputation Level)sanjanah_verma User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 7 h 16 m 13 sec
Reputation Power: 6
I am giving you the code which i am using now.This one was taken from web.It actually starts and stops a Stopwatch.Now what i want to do with this is,As soon as i load that page the timer should start.I included <body onload="findTime()"> in the code.But still the timer doesnot start when the page is loaded.If you can help me with this it'll be useful,Thanx in advance.

<html>
<body onload="findTime()">
<script language="javascript">
var base = 60;
var clocktimer,dateObj,dh,dm,ds,ms;
var readout='';
var h=1;
var m=1;
var tm=1;
var s=0;
var ts=0;
var ms=0;
var show=true;
var init=0;
var mPLUS=new Array(
'm0',
'm1',
'm2',
'm3',
'm4',
'm5',
'm6',
'm7',
'm8',
'm9'
);
var ii=0;
function clearALL() {
clearTimeout(clocktimer);
h=1;m=1;tm=1;s=0;ts=0;ms=0;
init=0;show=true;
readout='00:00:00.00';
document.clockform.clock.value=readout;
var CF = document.clockform;
for (ij=0;ij<=9;ij++) { CF[mPLUS[ij]].value = ''; }
ii = 0;
}

function startTIME() {
var cdateObj = new Date();
var t = (cdateObj.getTime() - dateObj.getTime())-(s*1000);
if (t>999) { s++; }
if (s>=(m*base)) {
ts=0;
m++;
} else {
ts=parseInt((ms/100)+s);
if(ts>=base) { ts=ts-((m-1)*base); }
}
if (m>(h*base)) {
tm=1;
h++;
} else {
tm=parseInt((ms/100)+m);
if(tm>=base) { tm=tm-((h-1)*base); }
}
ms = Math.round(t/10);
if (ms>99) {ms=0;}
if (ms==0) {ms='00';}
if (ms>0&&ms<=9) { ms = '0'+ms; }
if (ts>0) { ds = ts; if (ts<10) { ds = '0'+ts; }} else { ds = '00'; }
dm=tm-1;
if (dm>0) { if (dm<10) { dm = '0'+dm; }} else { dm = '00'; }
dh=h-1;
if (dh>0) { if (dh<10) { dh = '0'+dh; }} else { dh = '00'; }
readout = dh + ':' + dm + ':' + ds + '.' + ms;
if (show==true) { document.clockform.clock.value = readout; }
clocktimer = setTimeout("startTIME()",1);
}

function findTIME() {
if (init==0) {
dateObj = new Date();
startTIME();
init=1;
} else {
if(show==true) {
show=false;
} else {
show=true;
}
}
}


</script>


<form name=clockform>
<table cellpadding=2 cellspacing=0 border=0>
<tr>
<td><input name=clock size=12 value="00:00:00.00"></td>
</tr>
<tr>
<td><input name=clearer type=button value=" Reset " onclick="clearALL()"></td>
<td><input name=starter type=button value="Start / Stop" onclick="findTIME()"></td>
</tr>
</form>
</table>
</body>
</html>

Reply With Quote
  #6  
Old June 21st, 2004, 05:16 AM
manib_108 manib_108 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 20 manib_108 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
the code is working fine except for a few errors
1) the name of the findTime function is written in wrong cases at calls. Remember that the javascript is case sensitive
2) at line for (ij=0;ij<=9;ij++) { CF[mPLUS[ij]].value = ''; } delete the CF while accessing the array as the array is not the part of the form
otherwise the code is running ok but when u stop the watch shouldn't the values of text boxes set to zero
the code will work after the corrections

Reply With Quote
  #7  
Old June 22nd, 2004, 08:40 AM
sanjanah_verma sanjanah_verma is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 190 sanjanah_verma User rank is Corporal (100 - 500 Reputation Level)sanjanah_verma User rank is Corporal (100 - 500 Reputation Level)sanjanah_verma User rank is Corporal (100 - 500 Reputation Level)sanjanah_verma User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 7 h 16 m 13 sec
Reputation Power: 6
Hey got it working.I had been calling the function with the wrong name.Found it late.Thanx for ur help

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingASP Development > Timer/Stop Watch


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT