Math logic is used to dynamicaly do calculations based on user input. For example: If you need to add up the value of 2 fields you will use math logic.
NEX-Forms Documentation
Math Logic
What is Math Logic?
Math Logic with Text Fields
In this example you already added 2 fields called "Value 1" and "Value 2" like in the graphic above.
- Add a Math Logic field to your form.
- Edit the field (hover over the field and click on the icon).
- Click on the "Math Logic" tab on the field's settings
Now you will see a list of the current fields in your form and a field where you can add your math equation.
- Click on Value 1. It will be added to your formula
NOTE: If you have a field called "Number of Units" the field's math value place holder will be {number_of_units} - Add a plus sign as we want to add these 2 field's value's.
- Click on Value 2. It will be added to your formula
- Lets give this Result 2 decimal places.
- Now go back to your field's input settings to setup where to display the result.
- Add the math result placeholder "{math_result}" anywhere you need the calculation to be displayed.
or anything, like:
- Done...hit preview and see the math result spin to its calculated value.
Math Logic with Radio buttons & Check Boxes
In this example we will add a check box field and a radio button field to be multiplied.
The first thing you need to know is how to create vlaues for your check and radios to be different from the labels. For math logic these need to always be numeric!
The first thing you need to know is how to create vlaues for your check and radios to be different from the labels. For math logic these need to always be numeric!
- Add a check box field to your form and call it "Products"
- Click on the Field Input tab and add 3 options - Product A, Product B and Product C
- Now lets give Product A a value 100, Product B a value of 200 and Product C a value of 300. We do this by using the double equal (==). So its value==label. in this case we will have:
100==Product A
200==Product B
300==Product C - Add a radio button field to your form and call it "Quantity"
- Click on the Input tab and add 3 options - One, Two and Three
- Now lets give One a numeric value of 1, Two a numeric value of 2 and Three a numeric value of 3. We do this by using the double equal (==). So its value==label. in this case we will have:
1==One
2==Two
3==Three - Add a Math Logic field to your form.
- Click on the "Math Logic" tab on the field's settings
- Click on Quantity. It will be added to your formula
- Add a multiply (which is an asterisk (*)) sign as we want to multiply these 2 field's value's.
- Click on Products[] (the [] are there becouse is a multiple choose selection field). It will be added to your formula
- Now go back to your field's input settings to setup where to display the result.
- Add the math result placeholder "{math_result}" anywhere you need the calculation to be displayed.
or anything, like:
- Done...hit preview and see the math result spin to its calculated value.
Product A is 100 and Product B is 200 and we multiply it in the above graphic by 2 which equals 600.
Math Logic with Selects & Multi-selects
In this example we will add a 2 select fields to be devided.
- Add a select to your form and call it "Loan Amount"
- Click on the Input tab and add 5 amounts: 1000, 5000, 10000, 50000, 100000.
NOTE: Because our values are already numeric we dont have to use a double equal to specify values different from the labels. So in this case the label(displayd option) and the value is the same. So we just list the values.
- Add another select field to your form and call it "Loan Term"
- Click on the Input tab and add 4 loan terms and call then 3 Months, 6 Months, 1 Year, 2 Years
- Now lets give 3 Months a numeric value of 3, 6 Months a numeric value of 6, 1 Year a numeric value of 12 and 2 Years a numeric value of 24. We do this by using the double equal (==). So its value==label. in this case we will have:
3==3 Months
6==6 Months
12==1 Year
24==2 Years - Add a Math Logic field to your form.
- Click on "Loan Amount" from the select dropdown called form fields. It will be added to your formula
- Add a division (which is a forward slash (/)) sign as we want to devide these 2 field's value's.
- Click on "Loan Term" from the select dropdown called form fields. It will be added to your formula
- Now go back to your field's input settings to setup where to display the result.
- Add the math result placeholder "{math_result}" anywhere you need the calculation to be displayed.
For this example we will use "Your monthly installment will be ${math_result} without interest": - Done...hit preview and see the math result spin to its calculated value.
Using caculated totals in other equations
In this example we will use the form we created in the Math Logic and Selects above. We will add a new math logic field to use the calculated total of the one already added and then add 15% interest to it.
Please note that we are not teaching math but simply demonstrating NEX-Forms abilities. So the formulas might not make sense to actual mathematicians ;) .
VERY IMPORTANT: Your math result is stored by default into a hidden field called math_result. If this field name is not changed to something else you can not re-use it and it wont be emailed! So if you need to re-use totals performed by other equations in new equations or you need the calculated value to be emailed to you then you need to change the "Math Result Name" to something relevant like for example total_1, formula_1 or whaever is relevant to the equation
In this example we will name this math eqaution's result to be: installment_before_interest
Please note that we are not teaching math but simply demonstrating NEX-Forms abilities. So the formulas might not make sense to actual mathematicians ;) .
VERY IMPORTANT: Your math result is stored by default into a hidden field called math_result. If this field name is not changed to something else you can not re-use it and it wont be emailed! So if you need to re-use totals performed by other equations in new equations or you need the calculated value to be emailed to you then you need to change the "Math Result Name" to something relevant like for example total_1, formula_1 or whaever is relevant to the equation
In this example we will name this math eqaution's result to be: installment_before_interest
- Add a new Math Logic field to your form.
- Click on the "Math Logic" tab on the field's settings
- We know we called the previous math result installment_before_interest so we know that the we need to use it in an eqaution like this: {installment_before_interest}. Add {installment_before_interest} to the Math Equation
- Complete the formula: {installment_before_interest} + ({installment_before_interest}*15)/100
- Now go back to your field's input settings to setup where to display the result.
- Add the math result placeholder "{math_result}" anywhere you need the calculation to be displayed.
For this example we will use "Installment with 15% interest = ${math_result}":
- Done...hit preview and see the math result spin to its calculated value.
REMEMBER: Rename your math result fields to be re-used and/or to send it in your emails.