We are writing a form for finance, in the form there are two tables
What we want to happen, is that if the user selects Breakfast, then ONLY the Cost Per Day BESIDE the Reason on THAT particular row is changed to match the breakfast numerical value from the Table above it.(As roughly shown in the demo above, except it needs to happen automatically).
(Both Tables in Preview Mode with Class Name). Right now the way I am handling it is, if it detects a change on tblReason, then it loops through ALL remCostPerDay and if it detects a "0.00 value", it changes it, see code below. And this method works, and it's functional, but there are limitations too it(Such as when the user changes their mind). We want it that to when it's changed, the remCostPerDay beside tblReason happens on each row and doesn't affect all other rows tied to that class.
$('.cf-table-block').on('change','.tblReason select', function() { var reason = $(this).val(); var breakfast = $('.mieBreakfast input').val(); var lunch = $('.mieLunch input').val(); var dinner = $('.mieDinner input').val(); if(reason == "Breakfast"){ $(".remCostPerDay input").each(function(){ if($(this).val() == "0.00"){ $(this).val(breakfast); } }); } if(reason == "Lunch"){ $(".remCostPerDay input").each(function(){ if($(this).val() == "0.00"){ $(this).val(lunch); } }); } if(reason == "Dinner"){ $(".remCostPerDay input").each(function(){ if($(this).val() == "0.00"){ $(this).val(dinner); } }); } });
Any help on this would be greatly appreciated(Also note we did try this using Laserfiche Functions first, but due to a few issues we backed away from Functions and went with Javascript / Jquery).