Sum of multiple input fields if all input fields have same class in one input field by Jquery
<input type="text" class="pro_qty" value="" />
<input type="text" class="pro_qty" value="" />
<input type="text" class="pro_qty" value="" />
<input type="text" class="pro_qty" value="" />
<input type="text" class="pro_qty" value="" />
<input type="text" class="pro_qty" value="" />
<input type="text" class="total_qty" value="" />
<script>
$(document).on("change", ".pro_qty", function() {
var sum = 0;
$(".pro_qty").each(function(){
sum += +$(this).val();
});
$(".total_qty").val(sum); });
</script>
<input type="text" class="pro_qty" value="" />
<input type="text" class="pro_qty" value="" />
<input type="text" class="pro_qty" value="" />
<input type="text" class="pro_qty" value="" />
<input type="text" class="pro_qty" value="" />
<input type="text" class="pro_qty" value="" />
<input type="text" class="total_qty" value="" />
<script>
$(document).on("change", ".pro_qty", function() {
var sum = 0;
$(".pro_qty").each(function(){
sum += +$(this).val();
});
$(".total_qty").val(sum); });
</script>
No comments:
Post a Comment