iFormBuilder JavaScript Tips & Tricks
For steps on using basic JavaScript math functions within your form, please follow the instructions below.
Performing math calculations?
PLEASE NOTE: Other basic Javascript Math object functions can be performed as well by placing the Math.xxx(data_column_name) in the Dynamic value of the element. The xxx is the function that can be found in the Math Object Link in W3 Schools. Take a look at W3 Schools Math Object for a list of these functions.
iFORM TIP: When performing math operations, make sure you remember the order of operations and add parenthesis as needed.
For the following examples:
- Parent Form Name is calculating_math_form
- Element Data Column Names are: num1, num2, num3.
- Input Properties can be Text, Number, or Read Only element.
- Read-Only is suggested if you do not want to user to be able to change the numbers.
- Place all code in the Dynamic Value of the element that will be calculating the answer.
iFORM TIP: To prevent values from caching, you will need to use the full form path to clear values in the next record. Please note this form path is if the elements are on the parent level.
parent_form.element_name
ADDITION
Using Text Elements
If you're using Text elements, the JavaScript in your Dynamic Value should look like this:
Number(parent_form.num1)+Number(parent_form.num2)+Number(parent_form.num3)
iFORM TIP: When using the text element, change the Keyboard type to a Number Pad (as shown below). This will default the keyboard to the number keyboard for these elements.
Using Number Elements
If you're using Number elements, the JavaScript in your Dynamic Value should look like this:
parent_form.num1+parent_form.num2+parent_form.num3
SUBTRACTION
Using Text Elements
If you're using Text elements, the JavaScript in your Dynamic Value should look like this:
Number(parent_form.num1)-Number(parent_form.num2)-Number(parent_form.num3)
Using Number Elements
If you're using Number elements, the JavaScript in your Dynamic Value should look like this:
parent_form.num1-parent_form.num2-parent_form.num3
MULTIPLICATION
Using Text Elements
If you're using Text elements, the JavaScript in your Dynamic Value should look like this:
Number(parent_form.num1)*Number(parent_form.num2)*Number(parent_form.num3)
Using Number Elements
If you're using Number elements, the JavaScript in your Dynamic Value should look like this:
parent_form.num1*parent_form.num2*parent_form.num3
DIVISION
Using Text Elements
If you're using Text elements, the JavaScript in your Dynamic Value should look like this:
Number(parent_form.num1)/Number(parent_form.num2)/Number(parent_form.num3)
Using Number Elements
If you're using Number elements, the JavaScript in your Dynamic Value should look like this:
parent_form.num1/parent_form.num2/parent_form.num3
Device View
Comments
0 comments
Please sign in to leave a comment.