**Javascript** Tips and Tricks

For steps on using basic JavaScript math functions within your form, please follow the instructions below.

**PLEASE NOTE:** Other basic Javascript Math object functions can be performed as well by placing the **Math.xxx(data_col_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:**

- 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.

**ADDITION**

If you're using text elements, the JavaScript in your Dynamic Value should look like this:

**Number(num1)+Number(num2)+Number(num3)**

**iFORM TIP:** When using the text element, change the custom keyboard to a number keyboard (as shown below). This will default the keyboard to the number keyboard for these elements.

If you're using number elements, the JavaScript in your Dynamic Value should look like this:

**num1+num2+num3 **

**iFORM TIP:** To ensure the field doing the calculation resets to zero with each new record, set the elements to an empty string as shown in the image below.

**SUBTRACTION**

If you're using text elements, the JavaScript in your Dynamic Value should look like this:

**Number(num1)-Number(num2)-Number(num3)**

If you're using number elements, the JavaScript in your Dynamic Value should look like this:

**num1-num2-num3 **

**MULTIPLICATION**

If you're using text elements, the JavaScript in your Dynamic Value should look like this:

**Number(num1)*Number(num2)*Number(num3)**

If you're using number elements, the JavaScript in your Dynamic Value should look like this:

**num1*num2*num3 **

**DIVISION**

If you're using text elements, the JavaScript in your Dynamic Value should look like this:

**Number(num1)/Number(num2)/Number(num3)**

If you're using number elements, the JavaScript in your Dynamic Value should look like this:

**num1/num2/num3 **

## Comments

0 comments

Please sign in to leave a comment.