0

well the title matches what im in search for but to narrow it down ;),

im look for a numeric counter to add to my webpage, i wish the numbers to stretch to a unlimited value, adding numeric data from a table add to the counter without reset the counter by too 0.

would be entirely grateful for anyone that can help :)

<script>
('.myClassAbleToAddOnCounter').bind('click', function(){

var currentCount = parseInt($('#myCounterTotal').html());

var countToAdd = parseInt($(this).html());


('#myCounterTotal').html( currentCount + countToAdd );

});</script>
tymeJV
  • 103,943
  • 14
  • 161
  • 157
Sam1919
  • 3
  • 2

1 Answers1

0

Example of how you might make a counter in JavaScript..

function Counter(start) {
    this.value = this._initial = start || 0;
}
Counter.prototype.now = function () { return this.value; };
Counter.prototype.inc = function () { return ++this.value; };
Counter.prototype.add = function (x) { return this.value += x; };
Counter.prototype.reset = function () { return this.value = this.initial; };

Then

var c = new Counter();
c.inc();  // 1
c.inc();  // 2
c.add(5); // 7
Paul S.
  • 64,864
  • 9
  • 122
  • 138
  • Great thanks, i think thats the functioning done right?, now i just need to build up a counter template any ideas how this can be achieved? – Sam1919 Aug 02 '13 at 13:00