html - Jquery two different class using multiple input text subtraction -
i creating html page multi input value record display using jquery subtract 2 class value. please me
html
<tr> <td><input type="hidden" name="quarter_no[]" value="<?=$value->quarter_no?>">quarter <?=$value->quarter_no?></td> <td colspan="4"><input type="text" class="form-control" name="receipt_no[]" value="<?=$value->receipt_no?>" placeholder="quarter1 recept no."></td> <td><input type="text" class="form-control credited" id="quarter1_amtpaid" name="amount_credited[]" value="<?=$value->amount_credited?>" placeholder="0.00"></td> <td><input type="text" class="form-control deducted" id="quarter1_taxdeducted" name="amount_tax_deduction[]" value="<?=$value->amount_tax_deducted?>" placeholder="0.00"></td> <td><input type="text" class="form-control remitted" id="quarter1_taxremitted" name="amount_tax_remitted[]" value="<?=$value->amount_tax_remitted?>" placeholder="0.00"></td>
jquery
$(document).ready(function(){ $("body").on("blur", ".credited, .deducted", function(){ var arr = document.getelementsbyname('amount_credited[]'); var tot=0; for(var i=0;i<arr.length;i++){ if(parseint(arr[i].value)) tot += parseint(arr[i].value); } document.getelementbyid('quarter1_taxremitted').value = tot; }); })
<script> $(document).ready(function () { $(".credited , .deducted").on("blur", function () { console.log($('#quarter1_amtpaid').val()); var paid = $('#quarter1_amtpaid').val(); var deducted = $('#quarter1_taxdeducted').val(); var tot = parsefloat(paid) - parsefloat(deducted); $('#quarter1_taxdeducted').val(tot); }); }) </script>
try one.
Comments
Post a Comment