-1
私は、jqueryを使用してhtmlページの複数の入力値のレコード表示を作成しています2つのクラスの値を減算します。私Jquery 2つの異なるクラス複数の入力テキストの減算を使用して
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;
});
})
あなたの質問は正確ですか?何が間違っているかを推測する必要がありますか? – Rubenxfd