3
I’m setting up a function to do the calculation using percentage. My online test works.
$(document).ready(function () {
valorTotaldaNota = "1.000,00";
valorTotaldaNota = valorTotaldaNota.replace(",", "");
adValorem = "0.33";
gris = "0.20";
v1 = valorTotaldaNota * adValorem / 100;
v2 = valorTotaldaNota * gris / 100;
alert( v1 + v2 );
});
But in my local file, the calculation is not correct and appears a lot of zero in freight. Ex: 0.0087
$(document).ready(function () {
$(".seguro").click(function() {
valorTotaldaNota = $("#valorTotaldaNota").val();
valorTotaldaNota = (valorTotaldaNota.replace(",", ""));
adValorem = ($("#adValorem").val());
gris = <?php echo $gris; ?>
v1 = valorTotaldaNota * adValorem / 100;
v2 = valorTotaldaNota * gris / 100;
$("#valordoSeguro").val( v1 + v2 );
});
});
James put together an answer with a more elaborate explanation. I hope it will be useful.
– Sergio