Hi, Im ‘trying’ to write a checkbox type calculator. How can I do something along the lines of,
If 5 checkboxes are checked, apply a 2% discount to the total.
I am by no means an expert in javascript. I found a bit of jQuery
$(document).ready(function() {
var total = 0;
function calcTotal() {
$("input:checked").each(function() {
var value = $(this).attr("value");
total += parseFloat(value);
});
}
calcTotal();
$("input:checkbox, input:radio").click(function() {
total = 0;
calcTotal();
$("#total").val($.format('{a:.2f}', { a:total }));
});
});
The discounts are 2% off the total per each additional item selected. Eg if 6 items are selected then its 2% off the total, 7 items then its 4% off etc … max of 15 selectable