Check the fiddle: https://jsfiddle.net/1qbjd36c/13/
$("form .form-control").not("#thesum").on("input", function() {
var getSum = 0;
$("form .form-control").not("#thesum").filter(function() { if($.isNumeric($(this).val())) return $(this).val(); }).each(function() {
getSum+=parseFloat($(this).val());
});
$("#thesum").val(getSum);
});
$("form .form-control")
A tag and class selector has been utilized to reference the target.not("#thesum")
added a not selector in order to avoid the change of input of Resulting TEXT field.on("input", function() {
utilized ON-INPUT event, to trigger all input formats, which includes paste of clip text too..filter(function() {
utilized filter function to value only numeric values.getSum+=parseFloat($(this).val());
, here use of+
indicates summing upon with the previous value to the variable, in other words, recursive change on value, which returns the sum of all iterated values.
8
solved i want to sum 6 inputs and set the value to another input with javascript [closed]