0
I have a script, which is calculating, only that it brings me an integer, ie, if I calculate the values: 15,20 + 2,36 + 20,36 it will calculate only the integers, will bring me the result without the decimal place.
<script>
function calculatotal() {
var valor = $('#Valor').val();
var multa = $('#Multa').val();
var juros = $('#Juros').val();
var total = $('#Total').val();
if (valor == "") valor = 0;
if (multa == "") multa = 0;
if (juros == "") juros = 0;
if (total == "") total = 0;
var adicao = parseFloat(valor) + parseFloat(multa) + parseFloat(juros);
$('#Total').val(adicao);
}
$(document).ready(function () {
$('#Valor, #Multa,#Juros,#Total').blur(function () {
calculatotal();
});
calculatotal();
});
$(document).ready(function () {
calculatotal(); // calcula imediatamente ao carregar a página
$('#Valor, #Multa,#Juros,#Total')
.blur(function () { calculatotal(); }) // calcula ao perder o foco
.keyup(function () { calculatotal(); }); // calcula ao soltar a tecla
});
</script>
Can someone give me a hint?
Let me give you a hint: Javascript considers the American currency standard. The comma separates thousands and decimal points.
– Sam