Calculate the Sum of an Array Cost
-
Hi, I am trying to create a complex function like this using Calculated Fields Form:
User submits a number to fieldname 1 and fieldname 2.
For example, the total cost of level 2 to level 4 would be 200+500+500
(function(){ var startLevel = fieldname1, endLevel = fieldname2; var a = [ {level: 1, fee: 0}, {level: 2, fee: 200}, {level: 3, fee: 500}, {level: 4, fee: 500}, {level: 5, fee: 500}, ] var totalFee = 0 for(i=startLevel; i<endLevel; i++){ totalFee += a[i]?.fee } return totalFee; })();
However, whenever I Preview the code, it doesn’t show the final value totalFee on the Calculated Field.
Thank you a lot!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Calculate the Sum of an Array Cost’ is closed to new replies.