if( guessShipping < 15) // Sanity check, guessShipping should never be less than $15.00 guessShipping = 15.00;
return guessShipping; } </script>
Now that've written the above, it's not the best way of doing this calculation, but it should work. Copy and paste that code into your custom code block, then go to your total cost field as make it as a variable, say "totalCost". then create a new field ( or go to your current guesstimate field ) and enter this as your formula:
guessShipping(totalCost)
It will not work in the formBuilder, but if you save and preview the form, it should work.
being able to do this would save me a lot of time and redundant sections on my form, but i can't seem to figure it out based on what is above.
If i have a drop down menu on my form with 3 options, and i make that question a variable "DropD" with values 1,2,3. I then want to check to see if DropD is greater than 1 so i can edit a different variable, "DiffV" to give a Total "DiffV"'s value would be based on a selection from another drop down menu What i want to do is if DropD > 1 then multiply DiffV by .25 else DiffV is the Total
And then, would i enter Total(DropD) as a formula in the field (Question) where i wanted to display the result?
I have tried this but receive an error for the calculated field, but i'm not sure what i'm missing and if this should work i'll create a new form and start fresh with this fantastic new functionality
I think the issue probably is that javascript doesnt know what you are referring to by DiffV. Make sure you marked DiffV as a variable (which you did no doubt) then change your function header to: function Total(DropD,DiffV)
and call it as: Total(DropD,DiffV) in the formula.
If that doesn't work, let me know and I'll take a look on the form. (which form?)
Ok, i got one function working but i need to add two more, i've coded one thus far, but can't get it to work. It's below. It there any issue resulting from adding multiple scripts to the custom code section?
in javascript the comparison operator is: == not = (the assignment operator)
so when you say: if( DiscPer = 1 ) you are saying, " If you can assign the value one to the variable DiscPer, then do X " where as: if( DiscPer == 1 ) you are saying, " If the variable DiscPer equals 1, then do X "