I have the following code on a submission form. It changes the text color if the number is not normal.
$(document).ready(function(){ // detects changes in the "Scheduled Hours" table // filtered to only react to changes in the "hours worked" field // this "event bubbling" is usually the best way to deal with table rows $('.hoursTable table').on('change','.hoursWorked input',function(){ // get the value of the normal hours and the field that changed var normal = parseInt($('.normalHours input').val()); var actual = parseInt($(this).val()); // verify that both values are numbers and check if the actual is higher if(!isNaN(normal) && !isNaN(actual) && actual > normal){ // add a class to flag it for the highlighting $(this).addClass('abnormalHours'); } // otherwise, treat it like a normal field else{ $(this).removeClass('abnormalHours'); } }); });
It works great on the initial form, but will not work on the subsequent form.
Is there a way I can make it work on the secondary form? Ideally, I would also like it to be read-only, but can make due.
Here is what it looks like on the initial submission. On the second form, the color does not stay.
When the fields are populated from the first form to the second form, there is no change, so it does not run...at least that is what I am assuming. The code I am providing is the result from another question. I am new to coding so other than basic items, I am at a loss.