- This topic has 3 replies, 2 voices, and was last updated 12 years, 1 month ago by .
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);
});
- The topic ‘Classic Counter – Counting up from a number’ is closed to new replies.
