How to Use Math Formulas in Forms
FormCrafts has a powerful built-in math engine. It can be used to make order forms with complex pricing, quizzes, quotations, etc ... Math formulas work in real-time.
Before we learn about math formulas, we recommend reading about form variables, which is way of referencing form values in other parts of the form. Math formulas built on top of form variables.
Math formulas are contained within square brackets and support basic operators: + - / *. We always use field IDs within a math formula:
[field32 + ( field21 * 0.75 )]
Math formulas can be used in a text field, in the 'value' part of hidden fields, in the 'amount' part of Payment fields (like Stripe) and also in email content.
Checkbox, Dropdown, Showcase Fields, Star Rating, and Smiley Fields
The options of these fields contain two parts: a value, and a text. There is also an optional third part - image URL. When you edit the field you specify options under Option List, in this format:
In this case, the value is 32 and the text is Chocolate. The text is shown to the user, while the value is used by the math engine. If you are building a payment form the value would be your price.
With a datepicker field the value is the difference between the selected date, and today. If today is 1-Jan-2020, and the user selects 14-Jan-2020 in the field, the value used by the math engine is 14.
For a fileupload field the value used by the math engine is the number of files uploaded.
Matrix and Tabular Field
These fields are a composite of smaller fields, and don't have one value. They cannot be used in math formulas.