Form will not calculate totals when I use if-then statements in javascript
-
I need to have my form calculate a total cost estimate based on two things that the customer inputs into the form:
1. The customer’s tier (1, 2 or 3) – this determines base cost; all I want it to do is look up the base hourly rate based on the tier number they enter (so if 1, then 59, if 2, then 69, etc.)
2. The number of hours they’re purchasing (less than 4, 4 to 6, 7 to 9, and 10 or more) – this determines discount; all I want it to do is return the discount based on the number of hours they enter (so if 4, then 5%; if 8, then 10%, etc.)
Tier information is collected from “fieldname2” and hours are collected from “fieldname3”.
Discount script (calculated field stored in “fieldname5”):
(function(){
var v
if(fieldname3== 1) v = 0.05;
if(fieldname3== 2) v = 0.10;
if(fieldname3== 3) v = 0.15;
})();Tier value script (calculated field stored in “fieldname6”):
(function(){
var v;
if(fieldname2== 1) v = 59;
if(fieldname2== 2) v = 69;
if(fieldname2== 3) v = 89;})();
Nothing shows up in either calculated field, and the rest of the calculations in other fields need this information to show me results.
I have not tried to embed it yet as it is still not working in Preview mode.
- The topic ‘Form will not calculate totals when I use if-then statements in javascript’ is closed to new replies.