I am really really new to javascript and tried googling. but I don't find any luck. So please help me, everytime i input a value into a textbox. the other textbox's will show "nan" then when I tried to change the NaN Value, the first textbox that I typed in to will return the first thousand digits of the value.
here is the Fiddle of my proble
and these are my codes
$(document).on('change', '#family_home,#home_contents,#motor_vehicle,#Total', function() {
updateTotal();
});
var updateTotal =function() {
var a = parseInt($('#family_home').val());
$('#family_home').val(a.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
var b = parseInt($('#home_contents').val());
$('#home_contents').val(b.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
var c = parseInt($('#motor_vehicle').val());
$('#motor_vehicle').val(c.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","));
var total = parseInt(a)+parseInt(b)+parseInt(c);
$("#Total").html(total);
};
Please Please help. Thanks. I know im a newbie but I want to gain more knowledge from you guys. so please pass it on to me. Thanks