我已经设置了一个javascript代码来提供总计。我只需要将总数的4%添加到实际总数中。这就是我所拥有的
/* EXISTING WORKING TOTAL CODE */
$(function () {
$('.DoPricing').on("keyup",function () {
var total = 0;
$('.DoPricing').each(function () {
total += parseFloat($(this).val()) || 0;
});
$('#TotalPrice').html('$' + total);
});
});
/* NEW PERCENTAGE CODE BELOW THAT NEEDS INTEGRATED */
/* The code below is suppose to add 4% to total once integrated*/
var total = round_decimals(order_total, 2);
frm.TOTAL.value = total + ((4/100)*total);
答案 0 :(得分:1)
var total = 200;
total = total*1.04;
console.log(total); // 208
所以在你的情况下
$(function () {
$('.DoPricing').on("keyup",function () {
var total = 0;
$('.DoPricing').each(function () {
total += parseFloat($(this).val()) || 0;
});
$('#TotalPrice').html('$' + (total*1.04).toFixed(2));
});
});
将输出208.00作为总数200。