Hello,
I am not a js programmer, but i was hoping to find a prewritten script
that i may be able to use. all i need is a simple count up timer that
has a start, pause, and stop control to it, i have found some, but they
all seem to reset once you pause them, and i need it to stay where it
is at and then continue from the paused point once someone hits
restart.
if anyone knows where i can find something like this i would appreciate
it.
Thank you 11 1453
Bob wrote:
I am not a js programmer, but i was hoping to find a prewritten script
that i may be able to use. all i need is a simple count up timer that
has a start, pause, and stop control to it, i have found some, but they
all seem to reset once you pause them, and i need it to stay where it
is at and then continue from the paused point once someone hits
restart.
<html>
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<script language="javas cript" type="text/javascript">
i = 50 // bigger = slower, smaller = faster
tR = false
function sTime() {
++ document.c.cf.v alue
T = setTimeout('sTi me()', i)
tR=true;
}
function cTime(arg) {
if (tR) clearTimeout(T)
tR = false
if (arg == 1) sTime()
if (arg == 3) document.c.cf.v alue = 0
}
</script>
</head>
<body>
<form name="c">
<input type="text" name="cf" value="0">
<input type="button" value="Start" onClick="cTime( 1)">
<input type="button" value="Pause" onClick="cTime( 2)">
<input type="button" value="Reset" onClick="cTime( 3)">
</form>
</body>
</html>
Hope this helps,
--
Bart
Bob wrote:
Hello,
I am not a js programmer, but i was hoping to find a prewritten script
that i may be able to use. all i need is a simple count up timer that
has a start, pause, and stop control to it, i have found some, but they
all seem to reset once you pause them, and i need it to stay where it
is at and then continue from the paused point once someone hits
restart.
If you want a counter that resonably accurately counts seconds, you
need to use a date object and run the counter every 50ms or so to grab
the system time and use that to count in roughly equal seconds.
If you just want a counter that runs about every 100ms or so and time
accuracy is not important, then the script below will do the job.
<script type="text/javascript">
var pageCounter = (function()
{
var counterLag = 100; // Milliseconds between updates
var counterValue = 0; // Initial value
var counterRef; // Reference to current timer
var textElement; // Element to displaying value
return {
// Initialise values and start the timer if one isn't
// running already. Don't zero the counter
start : function(id)
{
if (!document.getE lementById) return;
textElement = document.getEle mentById(id);
if (!textElement) return;
if (!counterRef) pageCounter.run ();
},
// Run the counter - uses setTimeout to call itself
// reasonably regularly and update the counter.
run : function()
{
textElement.inn erHTML = counterValue++;
counterRef = setTimeout('pag eCounter.run()' , counterLag);
},
// Stop the counter but don't zero the counter
stop : function()
{
if (counterRef) clearTimeout(co unterRef);
counterRef = null;
},
// Stop and zero the counter
clear : function()
{
if (counterRef) pageCounter.sto p();
counterValue = 0;
textElement.inn erHTML = counterValue;
}
}
})();
</script>
<button onclick="pageCo unter.start('xx ')">Start</button>
<button onclick="pageCo unter.stop()">S top</button>
<button onclick="pageCo unter.clear()"> Clear</button>
<br><span id="xx"></span>
--
Rob
yeah, i need to have something that is pretty accurate, i need it to be
within a second or 2 after a 3 minute period.
another question: if i were to use it as a countDOWN, would this be
more accurate?
once again, thank you.
RobG wrote:
Bob wrote:
Hello,
I am not a js programmer, but i was hoping to find a prewritten script
that i may be able to use. all i need is a simple count up timer that
has a start, pause, and stop control to it, i have found some, but they
all seem to reset once you pause them, and i need it to stay where it
is at and then continue from the paused point once someone hits
restart.
If you want a counter that resonably accurately counts seconds, you
need to use a date object and run the counter every 50ms or so to grab
the system time and use that to count in roughly equal seconds.
If you just want a counter that runs about every 100ms or so and time
accuracy is not important, then the script below will do the job.
<script type="text/javascript">
var pageCounter = (function()
{
var counterLag = 100; // Milliseconds between updates
var counterValue = 0; // Initial value
var counterRef; // Reference to current timer
var textElement; // Element to displaying value
return {
// Initialise values and start the timer if one isn't
// running already. Don't zero the counter
start : function(id)
{
if (!document.getE lementById) return;
textElement = document.getEle mentById(id);
if (!textElement) return;
if (!counterRef) pageCounter.run ();
},
// Run the counter - uses setTimeout to call itself
// reasonably regularly and update the counter.
run : function()
{
textElement.inn erHTML = counterValue++;
counterRef = setTimeout('pag eCounter.run()' , counterLag);
},
// Stop the counter but don't zero the counter
stop : function()
{
if (counterRef) clearTimeout(co unterRef);
counterRef = null;
},
// Stop and zero the counter
clear : function()
{
if (counterRef) pageCounter.sto p();
counterValue = 0;
textElement.inn erHTML = counterValue;
}
}
})();
</script>
<button onclick="pageCo unter.start('xx ')">Start</button>
<button onclick="pageCo unter.stop()">S top</button>
<button onclick="pageCo unter.clear()"> Clear</button>
<br><span id="xx"></span>
--
Rob
Bob wrote:
yeah, i need to have something that is pretty accurate, i need it to be
within a second or 2 after a 3 minute period.
Well, RobG's 'counterLag'- and my 'i'-variable are actually the number
of milliseconds between each value change. Setting it to 1000 would be
the best option to approach a real second (but you can't trust that you
will have an accurate second here).
another question: if i were to use it as a countDOWN, would this be
more accurate?
That would make no difference as it depends on the same timer mechanism
anyhow.
--
Bart
JRS: In article <11************ **********@75g2 000cwc.googlegr oups.com>,
dated Mon, 7 Aug 2006 21:08:27 remote, seen in
news:comp.lang. javascript, RobG <rg***@iinet.ne t.auposted :
>Bob wrote:
>I am not a js programmer,
Therefore you should read the newsgroup FAQ before posting.
You should also give an informative Subject line.
>If you want a counter that resonably accurately counts seconds, you need to use a date object
Yes; or to be more exact a succession of such. It seems a pity that
there's no way of getting the date/time directly into an existing Date
Object - a .refresh() method is missing.
and run the counter every 50ms or so to grab the system time and use that to count in roughly equal seconds.
No need to call the system time more often than it will be used, unless
the interval is to be long. See in <URL: http://www.merlyn.demon.co.uk/
js-date2.htm>.
The following, simplified therefrom, will lock its count to the seconds
of the computer - note the last line of code :-
function Kount() { // var Kounter will be global
DynWrite("Down" , ++Kounter)
setTimeout("Kou nt()", 1050-new Date()%1000) }
Or see <URL:http://www.merlyn.demo n.co.uk/js-date0.htm#TaI>, function
Tock, contrasted with Tick.
--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/>? JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
JRS: In article <11************ *********@m79g2 000cwm.googlegr oups.com>,
dated Tue, 8 Aug 2006 08:52:59 remote, seen in
news:comp.lang. javascript, Bart Van der Donck <ba**@nijlen.co mposted :
>Bob wrote:
>yeah, i need to have something that is pretty accurate, i need it to be within a second or 2 after a 3 minute period.
Well, RobG's 'counterLag'- and my 'i'-variable are actually the number of milliseconds between each value change. Setting it to 1000 would be the best option to approach a real second (but you can't trust that you will have an accurate second here).
In *at least* some browsers, you can trust that you will not have an
accurate second, even on average.
Read the newsgroup FAQ.
--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/>? JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
ok, please allow me to rephrase to explain better,
i am not an EXPERIENCED js programmer, i am learning as i go, i read
the faq, however i thought this was a "HELP" forum, and i needed help.
I thank you to those that helped me, i have a better understanding now
of time counts on js and with what you have supplied i have solved the
problem.
Once again, thank you..
Dr John Stockton wrote:
JRS: In article <11************ **********@75g2 000cwc.googlegr oups.com>,
dated Mon, 7 Aug 2006 21:08:27 remote, seen in
news:comp.lang. javascript, RobG <rg***@iinet.ne t.auposted :
Bob wrote:
I am not a js programmer,
Therefore you should read the newsgroup FAQ before posting.
You should also give an informative Subject line.
If you want a counter that resonably accurately counts seconds, you
need to use a date object
Yes; or to be more exact a succession of such. It seems a pity that
there's no way of getting the date/time directly into an existing Date
Object - a .refresh() method is missing.
and run the counter every 50ms or so to grab
the system time and use that to count in roughly equal seconds.
No need to call the system time more often than it will be used, unless
the interval is to be long. See in <URL:http://www.merlyn.demon.co.uk/
js-date2.htm>.
The following, simplified therefrom, will lock its count to the seconds
of the computer - note the last line of code :-
function Kount() { // var Kounter will be global
DynWrite("Down" , ++Kounter)
setTimeout("Kou nt()", 1050-new Date()%1000) }
Or see <URL:http://www.merlyn.demo n.co.uk/js-date0.htm#TaI>, function
Tock, contrasted with Tick.
--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.c om/faq/>? JL/RC: FAQ of news:comp.lang. javascript
<URL:http://www.merlyn.demo n.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demo n.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.
Bob said the following on 8/9/2006 11:59 AM:
ok, please allow me to rephrase to explain better,
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
i am not an EXPERIENCED js programmer, i am learning as i go, i read
the faq, however i thought this was a "HELP" forum, and i needed help.
No, it is not a "help forum", it is a Usenet Discussion Group. You post,
it gets discussed. Nothing more, nothing less.
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
wow randy,
you need to get a life.. you have nothing better to do than to go
around and nitpick on "discussion forums" when someone asks a
question??
seriously, put down your mouse and your pocket protector, open up you
front door, you know, the big rectangle thing in the front of your
house, step through it and take a deep breath. then once you have
hopefully refreshed and realized that life is out there waiting for
you, you can come back here and not be such a sphincter muscle.
my 2 cents....
Randy Webb wrote:
Bob said the following on 8/9/2006 11:59 AM:
ok, please allow me to rephrase to explain better,
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
i am not an EXPERIENCED js programmer, i am learning as i go, i read
the faq, however i thought this was a "HELP" forum, and i needed help.
No, it is not a "help forum", it is a Usenet Discussion Group. You post,
it gets discussed. Nothing more, nothing less.
--
Randy
comp.lang.javas cript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Scotter |
last post by:
Okay I think my title line was worded misleadingly. So here goes again.
I've got quite 20 identical MDB files running on an IIS5 server.
From time to time I need to go into various tables and add a field or two.
It would be great if there were an application out there that could either:
(a) sync all MDB designs (and/or data) designated to match one I've added
some fields/tables to
OR
(b) go into all designated MDBs and create new...
|
by: glin |
last post by:
Hi Guys,
I am having problem finding the position of a button that I can set the
div position next to the button.
Can you please help? Thanks in advance.
|
by: Red Dragon |
last post by:
I am self study C student. I got stuck in the program below on quadratic equation and will be most grateful if someone could help me to unravel the mystery.
Why does the computer refuse to execute my scanf ("%c",&q);
On input 3 4 1 (for a,b and c) I had real roots OK
On input 1 8 16 I had same real roots OK.
However on 4 2 5, (for imaginary roots ) the computer cannot see the scanf ("%c",&q); statement. It just jumps...
|
by: dave m |
last post by:
I need to be able to retrieve a unique ID from a users PC. I needs to be
something a user could not easily change, like the computer name. Could
someone point me in the right direction to find the information found in
Windows system information? Or maybe there is a better method.
Thanks in advance for any help or suggestions.
Dave M.
|
by: Richard Lewis Haggard |
last post by:
We are having a lot of trouble with problems relating to failures relating
to 'The located assembly's manifest definition with name 'xxx' does not
match the assembly reference" but none of us here really understand how this
could be an issue. The assemblies that the system is complaining about are
ones that we build here and we're not changing version numbers on anything.
The errors come and go with no apparent rhyme or reason.
We do not...
| |
by: naheed javaid |
last post by:
I m student and doing my final project. My project is related to screen capturing.
my project captures screen and save the captured screen as bitmaps in a folder.
while the screen recording audio is also captured.i hve saved the captured audio as wav file.
i hve created avi form bitmaps only but i m not finding way how to add wav file to avi video.
i hve searched alot but not finding help.
if any body hve answer of my problem then pls reply...
|
by: U S Contractors Offering Service A Non-profit |
last post by:
This Sunday the 26th 2006 there will
be Music @ Tue Nov Inbox
Reply
Craig Somerford
to me
show details
9:54 pm (26 minutes ago)
#1St "CLICK" HeAt frOm A blanket
--http://mail.google.com/mail/?realattid=f_3n2tmv&attid=0.1&disp=inline&view=att&th=10f0d56e8cb478be
24 oct 2006
|
by: kalyankiran33 |
last post by:
I have com across a program in which I should take 17 as a global constant.
I have to take 17 inputs.
for those inputs ..
I have to find
the number of even numbers entered
the number of odd numbers entered
the number of prime numbers entered
smallest number among those 17
largest number among those 17
factorial of the smallest number
|
by: svbala |
last post by:
hi,
we have written a program in VC++ using arrays .The program is just basic C,but since the array size is too big we are unable to run the program so it is a must to use pointers .We also tried using malloc but it is giving us a lot of errors .Can anybody help us please.....
P.S.: We are using a library called free image so there will be some library functions used for gettin some functions like bits per pixel, height of the image and stuff...
|
by: NeoPa |
last post by:
Introduction:
This seems like a very straightforward topic. Why would anyone need help finding MS Access Help related to this topic?
I can't really answer that except to say that I know from experience that many do. I myself spent a great deal of time under the impression that it was non-existent.
How to Find it:
Different versions of MS Access structure their help systems differently, so don't expect it to be in the same place for each...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |