javascript - How would I add numbers to a total as check boxes are ticked? -


if go bottom of http://spareslist.com/listing.php?id=56, "item 1 - 6pts" when tick box next want add total offered points displayed next "what offer". "what offer - 12pts" if 2 6pts items selected.

firstly, need add element inside "what offer", id can reference jquery.

<h3>what offer <span id='totalpoints'>0</span> points</h3> 

secondly, need add points value checkboxes there add, , class jquery can reference them:

<input type="checkbox" name="offer-1" value="6" class="offer"> 

now can use jquery check checkboxes being ticked:

$('.offer').click(function() {     var points = $('#totalpoints').html();     if($(this).checked()) {         points += $(this).value(); //has been ticked     } else {         points -= $(this).value(); //has been un-ticked     }     $('#totalpoints').html(points); }); 

you'll need lot more that, started.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -