updated tallys
This commit is contained in:
parent
e51da4b4c1
commit
b51f490950
@ -319,20 +319,20 @@ for (let i = 1; i <= numRows; i++) {
|
||||
<SCRIPT>
|
||||
//Script to tally up all of the totals
|
||||
// get all the cells in the column
|
||||
const columnCells = document.querySelectorAll('#myTable td:nth-child(2)'); // change the selector to the desired column number
|
||||
// Get all input elements with IDs r1 through r14
|
||||
const inputs = document.querySelectorAll("#r1, #r2, #r3, #r4, #r5, #r6, #r7, #r8, #r9, #r10, #r11, #r12, #r13, #r14");
|
||||
|
||||
// initialize the total to zero
|
||||
let total = 500;
|
||||
// Initialize a variable to hold the total
|
||||
let total = 0;
|
||||
|
||||
// loop through each cell in the column and add its value to the total
|
||||
columnCells.forEach(cell => {
|
||||
const value = parseFloat(cell.textContent.value);
|
||||
console.log(value);
|
||||
if (!isNaN(value)) {
|
||||
total += value;
|
||||
}
|
||||
// Loop through each input element and add its value to the total
|
||||
inputs.forEach(input => {
|
||||
total += Number(input.value);
|
||||
});
|
||||
|
||||
// Output the total to the console
|
||||
console.log(total);
|
||||
|
||||
// display the total in the input box
|
||||
document.querySelector('#totalBox1').value = total.toFixed(2); // change the selector to the ID of the input box
|
||||
</SCRIPT>
|
||||
|
Loading…
Reference in New Issue
Block a user