Classic Counter – Counting up from a number

Author
Topic
#1851

Hello,

I have a counter, but I would like to incorporate your stylings. It’s a classic counter counting up from a start number, that begun on a start date. I realize that you have a countdown feature, but I dont see where to input a start number and change to counting up.

You can see my example here: http://www.spencerformanadvisory.com/

Along with javascript code:

var beginDate = new Date(“June 12, 2014 17:24:00”); //Your starting date
var interval = 3; // Count-up every three seconds
var increment = 1; // Number of ticks up per count
var startValue = 20600000; // What number to start from
var count = 0; // Count variable for calculation reference

$(document).ready(function(){

// Some new variables that play a part in calculation
var timeInterval = interval * 1000;
var now = new Date();
var toCalculate = ((now – beginDate) / timeInterval);

// Calculate the date FROM the beginning date
count = parseInt(toCalculate) * increment + startValue;

// Write the calculated value to the div with the inner ID
document.getElementById(‘counter’).innerHTML = count;
setInterval(“count += increment; document.getElementById(‘counter’).innerHTML = count;”, timeInterval);

});

Viewing 3 replies - 1 through 3 (of 3 total)
Author
Replies
  • #1852

    Hi,

    There are examples for different types of counts (including count up), and there is a documentation (docs folder in the plugin package) with all plugin settings and options. And there are few more examples in form of tutorials: http://www.smartplugins.info/tutorials/smart-timer-and-counter/

    The code you posted has nothing to do with my plugin, and I am not sure what I can help you with there.

    It is best you check out documentation PDF file first and examples that are included with the plugin. After that let me know if you have any problem using the plugin.

    Regards,
    Milan

  • #1855

    I’ve looked at the setting documentation, and I sort of understand how everything is supposed to work. What I’m looking to do is similar to the elapsed feature you’ve created, but instead what I want to do is have the counter increase at a 3 second interval and an increment of 1. Preferably from a starting value. As you can see in my code above I have it starting at a specific date in order to keep the counter going from a start value.

    How can I implement this into your code?

  • #1858

    Plugin has option to change interval for counting, but each interval is represented as 1. So, default interval is 1000, and if you put that to 3000 it will slow down counting 3 times, but it will still count 1 by 1, only the interval between changes is increased. From your code, you need this also.

    So, here is the example that has the interval changed from 1000 to 3000:

    var stceClockAnimated = jQuery('#stac-dev-animated').smartTimerCounter({
    	skin: 'Inline'
    	display: {},
    	timer: {
    		interval: 3000
    	}
    });

    You need the [b]timer[/b] bit to add to your code. It changes interval from 1000 (1 second) to 3000 (3 seconds).

    Milan

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Classic Counter – Counting up from a number’ is closed to new replies.