Form Calculations

Form fields can be computed using formulas. These formulas may refer to other questions in your form using variables. Formulas are written in Javascript and executed by the browser when filling out the form. They are defined using the Form Builder.

Note: For formulas to function properly, javascript must be enabled in the user's browser.

How to define a variable

A variable is a reference to a specific question in your web form. Its value is the answer provided by the respondent. It must be assigned to a question before it can be used in a formula.

  1. Open a form in the Form Builder.
  2. Click an existing question in the outline, or click 'add a question'.
  3. Open the Advanced tab.
  4. Check the "This is a variable in a calculated field" box.
  5. Enter a variable name for that question. Variable names may not contain space or non-alphanumeric characters.
  6. If you selected a multiple-choice question, you must provide a value for each choice.

How to create a formula

The formula is evaluated as the form is filled out. The form is submitted with the computed value. Form formulas are single line Javascript equations. They are mostly used to perform simple arithmetic, such as computing a total in an order form.

To create a computed field:

  1. Open a form in the Form Builder.
  2. Click an existing question in the outline, or click 'add a question'.
  3. Open the Advanced tab.
  4. Check the This is a calculated field check box.
  5. Enter an equation into the Formula text field.

Examples:

Here is an example of a simple formula performing arithmetic.

(a + b) / c * d

90% of the variable A, rounded to two decimals:

(A*0.9).toFixed(2)

Calculating a Body Mass Index (BMI)

height?(weight/((height/100)*(height/100))):0
// This example prevents a division by zero error by testing
// the height value first. It returns 0 if it's undefined or zero.

	

Interactive Tutorial

Conditional and Calculated Questions