hours += parseInt($(this).html()); no outputting decimals
Im currently using this code to calculate the total from a columns in a table
function calculateTotals() {
//these will hold the totals
var hours = 0;
//reference the rows you want to add
//this will not include the header row
var rows = $("#deliverables tr:not(:first-child, :last-child)");
rows.children("td:nth-child(2)").each(function() {
hours += parseInt($(this).html());
});
midHours = (hours).toFixed(2);
$(".total-hours").html(midHours);
};
However, the output midHours will not show decimals. For example a table
cell with value 12.5 - outputs as 12 in the .total-hours cell
Any feedback would help. Thanks!
No comments:
Post a Comment