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
Post a Comment