Hello guys I have a question about how to calculate the tax in jquery or in javascript? I have the following problem the user can select the tax it consists of 0%,6% and 21% I got 2000.12 in stead of 2.12 how can i fix this can anyone help me please????
This is my html code for the select what I am using
<select id="Btw">
<option value="0">0%</option>
<option value="6">6%</option>
<option value="21">21%</option>
</select>
Javascript
var subtotal = 0;
var NewBtw = 0;
var Totaal = 0;
$('.price').each(function(i){
price = $(this).html().replace("€","");
if (!isNaN(price)) subtotal += Number(price);
});
subtotal = roundNumber(subtotal,2);
NewBtw = roundNumber(NewBtw,2);
Totaal = roundNumber(Totaal,2);
var percentage = parseInt($("#Btw option:selected" ).val());
NewBtw = (subtotal / 100) * percentage;
Totaal = parseFloat((subtotal + NewBtw));
$('#subtotal').html(""+subtotal);
$('#BTW').html(""+NewBtw);
$('#total').html(""+Totaal);
Full code in this fiddle