I have the following situation: I am using jquery and I need to summarize some fields in my form. I found the NaN error in the intermediate field and . I tried my best to avoid this type of error, I just need SUM in this field. Everything in my form works fine, only with these two fields with the problem. I use parseFloat()and no answer. Only field with NaN
Follow my javascript code:
$(document).ready( function() {
$('#valor, #taxa, #imposto, #envio, #taxa_adicional, #subtotal, #total').blur(function(){
var val = $('#valor').format({format:"#,###.00", locale:"br"});
var tax = $('#taxa').format({format:"#,###.00", locale:"br"});
var imp = $('#imposto').format({format:"#,###.00", locale:"br"});
var env = $('#envio').format({format:"#,###.00", locale:"br"});
var xat = $('#taxa_adicional').format({format:"#,###.00", locale:"br"});
if(val == "") val = 0;
if(tax == "") tax = 0;
if(imp == "") imp = 0;
if(env == "") env = 0;
if(xat == "") xat = 0;
var subtotal = parseFloat("val") + parseFloat("tax") + parseFloat("imp") + parseFloat("env");
var total = parseFloat(val) + parseFloat(tax) + parseFloat(imp) + parseFloat(env) + parseFloat(xat);
$('#subtotal').format({format:"#,###.00", locale:"br"});
$('#total').val(total);
})
});
Thanks in advance for your help !: - /
WARNING: I am using the plugin:
jquery.numberformatter - Formatting / Parsing numbers in jQuery By Michael Abernethy
source
share