473,779 Members | 2,083 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Timer on webpages

Hi,

Im not sure where to find all the documentation i need for this? I need
to timer since a start button has been pushed, and show a counter on a
page. If they click stop i want to keep the time, and carry on
incrementing it if they click start again.

Any suggestions on code, or reference material for this?

Thanks for all the help

David

Apr 29 '06 #1
13 1498
On 2006-04-29, David <da************ @gmail.com> wrote:
Hi,

Im not sure where to find all the documentation i need for this? I need
to timer since a start button has been pushed, and show a counter on a
page. If they click stop i want to keep the time, and carry on
incrementing it if they click start again.

Any suggestions on code, or reference material for this?


Tricky one. I can't think of a way except using setInterval, with an
interval of about a second. In the callback you update the counter,
animation, etc., and increment a variable that counts how many seconds have
elapsed.
Apr 29 '06 #2
Ben C said the following on 4/29/2006 11:53 AM:
On 2006-04-29, David <da************ @gmail.com> wrote:
Hi,

Im not sure where to find all the documentation i need for this? I need
to timer since a start button has been pushed, and show a counter on a
page. If they click stop i want to keep the time, and carry on
incrementing it if they click start again.

Any suggestions on code, or reference material for this?
Tricky one.


Not really.
I can't think of a way except using setInterval,
There are other ways but setInterval would be the best way to update the
page itself. Not necessarily the best way to increment the counter though.
with an interval of about a second.
The resolution you used for setInterval would depend on how much
resource you would be willing to use and how accurate you wanted the
counter time wise.
In the callback you update the counter, animation, etc.,
and increment a variable that counts how many seconds have elapsed.


I don't agree with that one. Incrementing a variable would lead to
inaccuracies in the total. Just start with a Date object and compare the
current time, get the difference, and display it.

The only difference in this question and any other "running counter"
question is the Start/Stop buttons. And how you handled those would
depend, directly, on whether the OP wanted the timer to include the
Stopped time or not.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 29 '06 #3
JRS: In article <mM************ *************** ***@comcast.com >, dated
Sat, 29 Apr 2006 14:34:28 remote, seen in news:comp.lang. javascript,
Randy Webb <Hi************ @aol.com> posted :
In the callback you update the counter, animation, etc.,
and increment a variable that counts how many seconds have elapsed.


I don't agree with that one. Incrementing a variable would lead to
inaccuracies in the total. Just start with a Date object and compare the
current time, get the difference, and display it.


Using a Date Object to indicate duration will be unreliable in systems
where the clock is being automatically synchronised from time to time.

Using a Date Object naively to indicate duration will be unreliable when
the season changes between Summer and Winter.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demo n.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demo n.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Apr 29 '06 #4
Dr John Stockton said the following on 4/29/2006 5:25 PM:
JRS: In article <mM************ *************** ***@comcast.com >, dated
Sat, 29 Apr 2006 14:34:28 remote, seen in news:comp.lang. javascript,
Randy Webb <Hi************ @aol.com> posted :
In the callback you update the counter, animation, etc.,
and increment a variable that counts how many seconds have elapsed. I don't agree with that one. Incrementing a variable would lead to
inaccuracies in the total. Just start with a Date object and compare the
current time, get the difference, and display it.


Using a Date Object to indicate duration will be unreliable in systems
where the clock is being automatically synchronised from time to time.


If your app is that time critical, then you would know whether that was
happening or not and if you didn't allow for it then you get what you
deserve.
Using a Date Object naively to indicate duration will be unreliable when
the season changes between Summer and Winter.


And naively assuming that most business applications are being used on a
Saturday night at 2AM is indeed naive.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 30 '06 #5
Randy Webb wrote:
Dr John Stockton said the following on 4/29/2006 5:25 PM:
JRS: In article <mM************ *************** ***@comcast.com >, dated
Sat, 29 Apr 2006 14:34:28 remote, seen in news:comp.lang. javascript,
Randy Webb <Hi************ @aol.com> posted :
In the callback you update the counter, animation, etc., and
increment a variable that counts how many seconds have elapsed.
I don't agree with that one. Incrementing a variable would lead to
inaccuracies in the total. Just start with a Date object and compare
the current time, get the difference, and display it.


Using a Date Object to indicate duration will be unreliable in systems
where the clock is being automatically synchronised from time to time.


If your app is that time critical, then you would know whether that was
happening or not and if you didn't allow for it then you get what you
deserve.


Absolutely, so worth mentioning.

Using a Date Object naively to indicate duration will be unreliable when
the season changes between Summer and Winter.


And naively assuming that most business applications are being used on a
Saturday night at 2AM is indeed naive.


That is not naive at all - many businesses that have a production
process have shift work. I've frequently been involved in projects with
24hr shifts, 7 days per week over many months. That is common on
projects such as those that use very expensive CAD equipment, say a
major construction project.
--
Rob
Apr 30 '06 #6
RobG said the following on 4/29/2006 10:54 PM:
Randy Webb wrote:
Dr John Stockton said the following on 4/29/2006 5:25 PM:
JRS: In article <mM************ *************** ***@comcast.com >, dated
Sat, 29 Apr 2006 14:34:28 remote, seen in news:comp.lang. javascript,
Randy Webb <Hi************ @aol.com> posted :
> In the callback you update the counter, animation, etc., and
> increment a variable that counts how many seconds have elapsed.
I don't agree with that one. Incrementing a variable would lead to
inaccuracies in the total. Just start with a Date object and compare
the current time, get the difference, and display it.

Using a Date Object to indicate duration will be unreliable in systems
where the clock is being automatically synchronised from time to time.


If your app is that time critical, then you would know whether that
was happening or not and if you didn't allow for it then you get what
you deserve.


Absolutely, so worth mentioning.

Using a Date Object naively to indicate duration will be unreliable when
the season changes between Summer and Winter.


And naively assuming that most business applications are being used on
a Saturday night at 2AM is indeed naive.


That is not naive at all - many businesses that have a production
process have shift work. I've frequently been involved in projects with
24hr shifts, 7 days per week over many months. That is common on
projects such as those that use very expensive CAD equipment, say a
major construction project.


True, but that falls into the first category. That is a time critical
application and if you don't take care to account for it then you, well,
deserve what you get :)

But, your point is valid.

But, most sites that have a count-down/up timer are not business apps.
Some are, but most aren't. Probably a quiz type site that the OP has.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 30 '06 #7
JRS: In article <EN************ *************** ***@comcast.com >, dated
Sat, 29 Apr 2006 20:56:16 remote, seen in news:comp.lang. javascript,
Randy Webb <Hi************ @aol.com> posted :
Dr John Stockton said the following on 4/29/2006 5:25 PM:

Using a Date Object naively to indicate duration will be unreliable when
the season changes between Summer and Winter.


And naively assuming that most business applications are being used on a
Saturday night at 2AM is indeed naive.


It would be; but we should not be concerned just with "most" here; and
it is naive to assume that the clock necessarily changes at 2AM.

Then just consider all the Muslim and Jewish businessmen; the businesses
that run 24/7/366; the travellers who keep there portables set to Home
Time, ...

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demo n.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demo n.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Apr 30 '06 #8
Dr John Stockton said the following on 4/30/2006 5:50 PM:
JRS: In article <EN************ *************** ***@comcast.com >, dated
Sat, 29 Apr 2006 20:56:16 remote, seen in news:comp.lang. javascript,
Randy Webb <Hi************ @aol.com> posted :
Dr John Stockton said the following on 4/29/2006 5:25 PM:
Using a Date Object naively to indicate duration will be unreliable when
the season changes between Summer and Winter.

And naively assuming that most business applications are being used on a
Saturday night at 2AM is indeed naive.


It would be; but we should not be concerned just with "most" here; and
it is naive to assume that the clock necessarily changes at 2AM.


And this entire scenario falls into the part of my reply that you snipped:

<quote>
If your app is that time critical, then you would know whether that was
happening or not and if you didn't allow for it then you get what you
deserve.
</quote>
Then just consider all the Muslim and Jewish businessmen; the businesses
that run 24/7/366; the travellers who keep there portables set to Home
Time, ...


I am not sure what being Muslim or Jewish has to do with that.

But, it still falls into the first category.

--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
May 1 '06 #9
JRS: In article <O6************ *************** ***@comcast.com >, dated
Sun, 30 Apr 2006 22:37:29 remote, seen in news:comp.lang. javascript,
Randy Webb <Hi************ @aol.com> posted :
Dr John Stockton said the following on 4/30/2006 5:50 PM:
JRS: In article <EN************ *************** ***@comcast.com >, dated
Sat, 29 Apr 2006 20:56:16 remote, seen in news:comp.lang. javascript,
Randy Webb <Hi************ @aol.com> posted :
Dr John Stockton said the following on 4/29/2006 5:25 PM:

Using a Date Object naively to indicate duration will be unreliable when
the season changes between Summer and Winter.
And naively assuming that most business applications are being used on a
Saturday night at 2AM is indeed naive.


It would be; but we should not be concerned just with "most" here; and
it is naive to assume that the clock necessarily changes at 2AM.


And this entire scenario falls into the part of my reply that you snipped:

<quote>
If your app is that time critical, then you would know whether that was
happening or not and if you didn't allow for it then you get what you
deserve.
</quote>


Don't assume that questioners and readers are as intelligent as you
think you are.
Then just consider all the Muslim and Jewish businessmen; the businesses
that run 24/7/366; the travellers who keep there portables set to Home
Time, ...


I am not sure what being Muslim or Jewish has to do with that.


Knowing nothing about other cultures is part of being a WASP, no doubt.
FYI, those people do not regard Sunday as the ordained Day of Rest.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demo n.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demo n.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
May 1 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
7498
by: Manuel Lopez | last post by:
I have a puzzling form timer problem that I didn't experience prior to Access 2003 (though I'm not sure access 2003 is to blame). Here's the situation: a computer has two access 2003 databases on it, a frontend and a backend. Case 1: If vba code on the frontend updates many rows (360,000) on the backend, a form's timer event (from the frontend) will stop firing until the user gives the form focus. (Note that the update itself always...
2
1529
by: DaveF | last post by:
I am trying to write a service to fire an ftp object off. I want to wait 2 minutes and then download the files. Then repeat every 2 minutes. The files just seem to stop downloading. Does that timer go off every 2 minutes if the files are done or not? Here is the code: using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Diagnostics;
9
7287
by: HL | last post by:
I am using VS 2005 Beta - C# Problem: The Timer fires a few milliseconds before the actual Due-Time Let's say a timer is created in the following manner: System.Threading.Timer m_timer = null; Let's declare a constant Int32 m_TimePeriod = 10000;
3
2700
by: Yul | last post by:
Hi, We are in the process of designing an ASP.NET app, where a user will enter some 'Customer ID' to be queried in the database. If the ID is valid, several stored procedures will be called to populate multiple webpages containing customer information. There isn't a one-to-one correlation between the stored procedure and a webpage. In other words, a webpage may have to refer to 1 or more DataTables to populate itself. Therefore, a...
12
2807
by: scsharma | last post by:
Hi, I am working on creating a webapplication and my design calls for creating main webform which will have menu bar on left hand side and a IFrame which will contain all the forms that are shown when menu items are clicked.Besides these i would like to put a custom status bar. Any error message encountered in any of the webpage will be displayed in the banner. The problem iam encountering is how to access the customer status bar in child...
2
4065
by: John David Thornton | last post by:
I've got a Windows Service class, and I put a System.Threading.Timer, and I've coded it as shown below. However, when I install the service and then start it in MMC, I get a peculiar message: The MyService service on Local Computer started and then stopped. Some services stop automatically if they ahve no work to do, for example, the Perforamnce Logs and Alert service. I tried switching to a System.Threading.Timer and that didn't work...
12
5535
by: Gina_Marano | last post by:
I have created an array of timers (1-n). At first I just created windows form timers but I read that system timers are better for background work. The timers will just be monitoring different directories and updating a database. No interaction with the GUI. Problem is that the system timers do not have a tag property so I can tie in an object. example (old way):
8
2664
by: =?Utf-8?B?RGF2ZSBCb29rZXI=?= | last post by:
I have a Timer that I set to go off once a day, but it frequently fails! In order to debug I would like to be able to check, at any moment, whether the Timer is enabled and when it will next Elapse. Is there any way -- whether in my code, or in the O/S -- to determine when a Timer is scheduled to Elapse?
16
3257
by: Peter Oliphant | last post by:
Note that although this involves SAPI, it is more a question about Timers and event handlers. I wrote a Speech Recognize handler (SAPI), and put some code in it to enable a Timer. It would not do it. If I bring this same code outside this event handler, it works just fine. Is this normal?
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10305
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10137
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9928
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7483
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6724
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5503
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.