increment variable according to numbers of clicks
<p>I have following code:</p>

<p>javascript:</p>

<pre><code>var counter = 0;
var totalItems = 8;
var restItems = $num-totalItems;
if (restItems==22) {
    $('#next').click(function(e) {
        e.preventDefault(); 
        counter++;
        updatestatus();     
    });
}     

function updatestatus() {   
    totalItems = totalItems + 8 * counter;
}
</code></pre>

<p>HTML:</p>

<pre><code>&lt;input type = "button" id="next" value="click me"&gt;
</code></pre>

<p>what I want is that before I click the button, the totoalItems is equal to 8, and each time when I click it, the totoal item is added by 8, but at the moment that bit of code dosen't work and give me a very large number, any one could help me figure it out, thanks a lot.</p>
