I'm trying to sum some fields into a 'final input.'
I have input
id #TotalFR
and I would like that, as fields #CFR1
, #CRF2
, #CRF3
, #CRF4
and #CRF5
are filled, the sum of this is displayed in #TotalFR
. I'm using the script but I get the NAN value in response.
$('.vut').blur(function(){
var id=$(this).attr("id").substr(3,1);
$.ajax({
url : 'custofr.php',
type : 'POST', /* Tipo da requisição */
data: 'FR1=' + $('#FR'+id).val() + '&VUT1=' + $('#VUT'+id).val(),
dataType: 'json',
success: function(data){
if(data.sucesso == 1){
$('#CFR'+id).val(data.CFR1);
var Valor1=parseFloat($('#CFR'+id).val());
var Valor2=parseFloat($('#TotalFR').val());
var TotFR = Valor1 + Valor2;
$('#TotalFR').val(TotFR);
}
}
});
return false;
})