私は、テキストボックスの行を含むテーブルを、css .hoursで数値/時間を保持する入力として持っています。行が削除されたらto get the table to update totals
を試していますcheckbox is checked
/clicked。チェックボックスJavaScriptは値を更新しません
行の合計を更新するには& colを最後に更新しますか? 行削除チェックボックスがオンの場合はとなります。
2ステップ:削除された行の値をゼロにしてから、新しい合計を更新します。
// Call this function, When CheckBox with css .deleteRowis clicked
$('#Maintable').on('click', '.deleteRow', function()
{
if ($(this).is(":checked")) {
var row = $(this).closest('tr').css({ 'color': 'red' });
var hours = row.find('.hours');
$.each(hours, function (index, item) {
if ($(this).val()) { // if there is a value
$(this).val('0');
// Total the rows does not work??
HoursChangedFunction($(this));
}
});
} // :checked ends
// when the row is deleted from the checkbox, find it and call this function
// 1) First make all .hours 0, 2) and then redo the totals
var HoursChangedFunction = function() {
var columnIndex = $(this).closest('td').index();
var row = $(this).closest('tr');
var hours = row.find('.hours');
var rowTotal = 0;
$.each(hours, function (index, item) {
rowTotal += Number($(this).val());
});
row.children('td.rowtotal').text(rowTotal.toFixed(2));
var columnTotal = 0;
var grandTotal = 0;
var rows = $('#Maintable tr');
$.each(rows, function (index, item) {
columnTotal += Number($(this).children('td').eq(columnIndex).children('.hours').val());
grandTotal += Number($(this).children('.rowtotal').text());
});
footer.eq(columnIndex).text(columnTotal.toFixed(2));
total.text(grandTotal.toFixed(2));
};
フッター&合計は未定義で、フッターは何ですか? – Nicholas
@Nicholasフッターは、 '' everyday column'の '' totals'の最後の行です。私は秒で追加します – transformer
@Nicholasそれは本当にテーブルフッターである 'tfoot'でなければなりません – transformer