foreach (TSM.Models.Tasks itm in lstTasks.Where(x => x.Project.ID == item.ID).ToList())
{
<tr id="tmsData">
<td> </td>
<td>@itm.TaskName</td>
@for (int i = 1; i < 8; i++)
{
<td > <input class="txtTaskHours date@(Date.AddDays(i).ToString("MMddyyyy"))" style="width:50px;" type="number" id="@(itm.ID.ToString() + ':' + Date.AddDays(i).ToString("MMddyyyy"))" /></td>
}
<td><strong><input class="JKL" style="width:50px" /></strong></td>
</tr>
<tr>
</tr>
}
}
<tr>
<td></td>
<td></td>
@for (int i = 1; i < 8; i++)
{
<td ><strong><input class="JKLL " id="Tue" style="width:50px" /></strong></td>
}
<td></td><script>
$(document).ready(function () {
$(".txtTaskHours").on('keyup change', calculateSum);
});
function calculateSum() {
var $input = $(this);
var $row = $input.closest('tr');
var sum = 0;
$row.find(".txtTaskHours").each(function () {
sum += parseFloat(this.value) || 0;
});
$row.find(".JKL").val(sum.toFixed(2));
//adding column values
var eid = ($input.attr('id'));
var arrTaskTextBoxes = $('.date' + eid.substr(eid.indexOf(":") + 1, 8));
var sum = 0.00
for (var i = 0; i < arrTaskTextBoxes.length; i++) {
if (arrTaskTextBoxes[i].value != '') {
sum+= parseFloat(arrTaskTextBoxes[i].value) || 0;
}
}
$(".JKLL").val(sum.toFixed(2));
//document.getElementById('Tue').value = sum.toFixed(2);
console.log(sum);
}
This is my script code i tried this but when sum of column is take
place then if we fill data in top to bottom then its show sum in whole of the
textbox
. Row sum is done very properly way but sum of the column issue is
coming sum of column show is correct but is sow all the text boxes that is
give in the bottom row. I use this script method here i am using eid by which
id of every textbox we take.