I have a Vacation Payout Request process in Laserfiche Forms. On the form is a table to calculate Vacation, Sick, Comp Time Off (CTO) balances. I'm trying to use JavaScript to calculate the Balance Remaining for the Vacation column. In the example below, I added the first 2 cells (50 + 30) and subtracted the third cell (10) to get the fourth cell's expected value, "4. Balance Remaining" (70).
The following JavaScript is not displaying anything in the "4. Balance Remaining" cell. I would like it to display the running balance as numbers are added in the top 3 cells in the Vacation column.
$(document).ready(function() { // When Vacation value is changed in the first 3 rows on the 'Leave Credits' table, // update the Vacation balance remaining in row 4 $(this).getElementById('Field38(1)').onChange = updateVacBal(); $(this).getElementById('Field38(2)').onChange = updateVacBal(); $(this).getElementById('Field38(3)').onChange = updateVacBal(); // Function to perform the desired operation function updateVacBal() { // Get the values from the specified cells var r1c3 = parseFloat($(this).getElementById('Field38(1)').val()); var r2c3 = parseFloat($(this).getElementById('Field38(2)').val()); var r3c3 = parseFloat($(this).getElementById('Field38(3)').val()); // Perform the calculation: (Row 1, Column 3) + (Row 2, Column 3) - (Row 3, Column 3) var result = r1c3 + r2c3 - r3c3; // Assign the result to Row 4, Column 3 $(this).getElementById('Field38(4)').val() = result; } }