0

I found this https://github.com/inorganik/CountUp.js
As my knowledge of javascript is very weak, i am asking for your help to store the counter result local, then display it on the user`s browser...

   var options = {
      useEasing : true, 
      useGrouping : true, 
      separator : ',', 
      decimal : '.', 
      prefix : '', 
      suffix : '' 
    };
    var demo = new CountUp("myTargetElement", 0, 9999999, 0, 998.9, options);
    demo.start();

Like this, it will count forever ( i think )

Many Thanks!

4
Contributors
12
Replies
65
Views
2 Years
Discussion Span
Last Post by Norbert_2
Featured Replies
  • 1
    diafol 3,669   2 Years Ago

    How about a start time having an offset, e.g. $time = time(); $offset = 27485997; //or whatever $time += $offset; Then in your html page <script> var startTime = <?=$time?>; //then increment a standard setInterval event to incement the time every second </script> This means everybody gets the current time … Read More

0

What exactly are you having trouble with? What vaule do you want to store (the start or end value of the counter maybe)?
This script really is simple to use: set up a div you want to hold the counter, add the CountUp js file and call the method. Clearly you want to do something more than that. A deeper explanation would help us out.

0

Well i want to store the counted value + keep counting on every times the page is visited, so if the count now is 100, you visit apage.php/html, counter keeps counting, so let`s say the number has reached 350, then somebody else visits the page, again, the counter keeps counting from the last number(350) + ....

Now do you understand what i am searching for?

0

I don't think js is the way to go. You need a server-side solution. Javascript just works on the local (client) machine - nothing is passed to the server as a rule (unless via Ajax).

Are you using server-side tech like PHP, ASP, Java, NodeJS ? If so, which one. This would be a trivial piece of code - a handful of lines maybe.

0

I am using PHP, Here is my website: liveguardmu.com
As you can see i have a counter there, i made it somehow, but i don`t like it...
Right now current count is stored into a .txt file, i reach it on every client, and count again via PHP. Please give me ideas/examples -_-

0

Sorry can't see any counter on there. Anyway, depends on what you need - unique counts or total counts

Edited by diafol

0

Check Again please, on the right sidebar.
Totsal counts, i will display the total counts.
I will explain again:

You visit my page, counter starts, as long as you stay on my page counter keeps counting, but in the mean time another person visits my page, the counter continues to count from the last number that the counter was while you are on my page. Does this make any sense?

0

I saw the counter - Threats Blocked?

It just seems to be counting up every second or so. I can't see what purpose this has within the context of the page.

What happens if you have concurrent visitors? E.g. 20 visitors at a time? Do you update 20 times per second?

Are you updating a text file on the server every second? If so, every client on your site will be forcing an increment, won't they?

I'm really at a loss as to what you're trying to show. I understand you want to increment the counter while your page is in somebody's browser - but I'm not sure why.

0

Yes, you are so right. I think at the moment i am overclocking my webhost :)) haha. Anyway, let me reformulate:

-The counter should count in the background independent
-The counter show display the same result to all visitors

Sounds better?

1

How about a start time having an offset, e.g.

$time = time();
$offset = 27485997; //or whatever
$time += $offset;

Then in your html page

<script>
    var startTime = <?=$time?>;
    //then increment a standard setInterval event to incement the time every second 
</script>

This means everybody gets the current time + offset (offset could be a negative value). Then you don't have to store anything. Pretty pointless, but is that what you want?

Edited by diafol

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.