0

Hi all..

I am doing the display board for my company.
My problem is I don't have any idea how to count every minutes that given.
Like every 5 minutes it count 1 then 5 minutes later it count 2 until the certain time.
Can anyone give me some hint or example?
Thanks in advance.

5
Contributors
19
Replies
20
Views
5 Years
Discussion Span
Last Post by Biiim
0

Can I possible to do the stop counting by itself then start back the counting automatically too?

0

Try searching for php Iteration or implementing IteratorAggregate in php. That should do it with switch function.

0

Then try setInterval(expression, interval) to start the timer and clearInterval(intervalID) to stop the timer.
seltInterval(expression, interval) invoke the given expression continuously with given time interval

var intervalID = seltInterval( "doSomething()", 5000 );

clearInterval(intervalID) clears the timer.

clearInterval(intervalID);

To start again call seltInterval again

Edited by niranga: n/a

0

Is it the seltInterval take the previous stop time or the current time in machine?

0

Hi..
I already have the counting code but it must click the start and stop function.
but the problem is I want the system run without need to click start and stop button. And also how can I set the time when it is start and when it is stop.

This is my code

count.php

<html>
<head>
<script type="text/javascript">
var c=0;
var t;
var timer_is_on=0;

function timedCount()
{
document.getElementById('txt').value=c;
c=c+1;
t=setTimeout("timedCount()",480000);
}

function doTimer()
{
if (!timer_is_on)
  {
  timer_is_on=1;
  timedCount();
  }
}

function stopCount()
{
clearTimeout(t);
timer_is_on=0;
}
</script>
</head>

<body>
<form>
<input type="button" value="Start count!" onClick="doTimer()">
<input type="text" id="txt">
<input type="button" value="Stop count!" onClick="stopCount()">
</form>
</body>
</html>
0

It's work niranga!
How about the stop function?

0

When do you want to stop it? I mean on what condition?

Edited by niranga: n/a

0

Actually I want to set the time when it's start count and when it's stop counting.
Is it possible for me to do it?

0

You are saying, you have a fix duration and just after that time elapsed you want to stop the timer?

0

Then use a variable to hold the seconds you need to count and reduce it one by one until it reaches zero. Soon after it becomes zero call stopCount()

0

Can you give me some example?I can't get it.Sorry for your inconvenience.

0
function timedCount(){
	document.getElementById('txt').value=c;
	c=c+1;
	if(c == 5){
		c = 0;
		stopCount();
	}else{
		t=setTimeout("timedCount()",480000);
	}
}
0

Hi.
I already do this function.
Can you remark me where is the mistake?

function timedCount()
{
document.getElementById('txt').value=c;
c=c+1;
if(c == 14){
		c = 0;
		continue();
	/*}else{*/
		t=setTimeout("timedCount()",1000);
	}
0

Hi.
I already do this function.
Can you remark me where is the mistake?

function timedCount()
{
document.getElementById('txt').value=c;
c=c+1;
if(c == 14){
		c = 0;
		continue();
	/*}else{*/
		t=setTimeout("timedCount()",1000);
	}

you've commented out the else statement, c will not equal 14 at first so timeCount() will not be called again. It's there so timedCount() will keep running until c equals 14, once c equals 14 it sets c to 0 and runs a function called continue() and won't run timedCount() again

function timedCount()
{
document.getElementById('txt').value=c;
c=c+1;
alert('timedCount called. c = '+c);
if(c == 14){
		c = 0;
		continue();
	}else{
		t=setTimeout("timedCount()",1000);
	}

Edited by Biiim: add an alert

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.