Need Script Help For Conditionals
Good evening,
I have been working on this tiny script for days with little success.
I am working on a mileage reimbursement form. My job is in Finance - I am not a programmer by any means. My team has been using an inherited Excel form from 1996, and would prefer the e-signature ability of the Adobe forms our staff are used to using. I could do what I'm trying to do if I added a subtotal field, but I'm trying to minimize.
Person will enter their usual commute mileage (text field name = Commute)
They will check a box if their trip includes mileage to or from their home. (checkbox name = HomeR1)
They will check a box i f theyr mileage is round trip. (checkbox name = RTR1)
The subtotal mileage for the trip is entered (text field name = MiR1)
Now the final field is Total Miles (TtlR1) I want this value to show MiR1 minus the commute mileage (Commute) if the (HomeR1) checkbox is selected, or subtract 0/stay the same if the box is unmarked. THEN I would like it to double if the (RTR1) checkbox is selected for round trip.
I am able to get the subtracting or the doubling (see code), but if both boxes are checked it's not taking the deduction twice...
var newValue = 0;
if (this.getField("HomeR1").value!="Off")
newValue -= Number(this.getField("Commute").value);
if (this.getField("RTR1").value!="Off")
newValue += Number(this.getField("MiR1").value*2);
event.value = newValue;I'm both embarassed and frustrated because it feels like it should be not be so difficult - I am very strong in Excel, and have been working in PowerBI but this is escaping me.
I appreciate any advice or assitance, thank you for your time, and I apologize for the novel: was trying to be clear.
