次の表に合計額と割引額を計算する必要があります。Javascriptを使用してテーブル行に計算された合計と割引を取得する必要があります
<tbody id="generate_invoice_table">
<tr>
<td>16</td>
<td>Glass Polish Normal</td>
<td><input type="text" class="form-control text-right quantity" value="1"></td>
<td class="price">8000.00</td><td><input type="text" class="form-control text-right discount"></td>
<td><input type="text" disabled="" class="form-control text-right amount"></td>
<td><input type="checkbox" checked="" name="check-invoice"></td>
</tr>
</tbody>
基本的に、数量を入力してから割引を入力し、最後の入力ボックスに金額を表示します。 Javascriptのは...私はtrs.find
は関数ではありませんメッセージを取得するには、下記のvar t=
と
$('#invoice').delegate('.quantity,.price,.discount', 'keyup', function() {
var t = document.getElementById("generate_invoice_table");//find table data
var trs = t.getElementsByTagName("tr");
var qty = trs.find('.quantity').val();
var price = trs.find('.price').val();
var dis = trs.find('.discount').val();
varamt = (qty * price) - (qty * price * dis)/100;
trs.find('.amount').val(amt);
total();//calculate total and show after the invoice table
});
});
function total() {
var t = 0;
$('.amount').each(function (i, e) {
varamt = $(this).val() - 0;
t += amt;
});
$('.total').html(t);
}
に役立ちます。どちらか一方を使用してください。 jQueryオブジェクトではないコレクションに対してjQueryメソッド 'find()'を使用しようとしています – charlietfl