Webform Calculator (Formula) module in the WMS


OVERVIEW

Target audience: Site Administrators, Site Managers, Site Editors

The Webform Calculator module in the Web Management System (WMS) provides a Formula field that can be used with other components to display the results of computations.

Notes: Site Administrators and Site Managers can create webforms while Site Editors may edit but not publish webforms.

Supported operations and symbols are as follows:

OperationSymbol
Addition+
Subtraction-
Multiplication*
Division/
Start expression(
End expression)

How to use the Formula component

The following example shows how to create a School supplies and stationery form and calculates the cost of various items for an order.

  1. Add a Number component to your webform.
    • Use this field to show the cost of Lab Book 200-page
    • In the Default value field, enter 7.50

      Add default value

    • To disallow users from changing the cost of the Lab Book 200-Page item, check the Disabled option under DISPLAY

      disabled checkbox

    • Click Save component

  2. Add and save another Number component
  3. Add a Formula component labelled Total

    formula component

    • Click on TOKEN VALUES to see the list of available tokens
    • To show the sum of the two items when added, enter the following in the Formula value field:
      {lab_book_200_page} + {physics_lab_book}
      Be sure to leave a space between the tokens and the operator

      formula value

    • Save component

  4. View the form.
    • The Total shows the result when the price of the Lab Book 200-Page is added to the price of the Physics Lab Book

      view form

  5. Use additional Number fields so users can indicate the quantity of items they would like to order. Note that each item must have its own quantity field.
    • Return to Form components and add a new Number field labelled Quantity (Lab Book 200-Page)
    • Leave the Default value blank and the Disabled option unchecked since users should be allowed to enter this information
    • Click Save component
    • Back on the Form components page, Clone the Quantity (Lab Book 200-Page) component
    • Change the Label and Form Key so that it refers to Physics Lab Book instead of Lab Book 200-Page
    • Save component

  6. Update the Total component to include the additional number fields
    • Click on TOKEN VALUES to see the new tokens
    • Enter the following in the Formula value field:
      {lab_book_200_page} * {quantity_lab_book_200_page} + {physics_lab_book} * {quantity_physics_lab_book}
      Be sure to leave a space between the tokens and the operators

      formula value

    • Save component

  7. Rearrange the Form components so that each quantity field follows its corresponding item

    rearrange form components

    • Click Save

  8. Select View draft and test the form before publishing
    • Enter different values in the quantity fields. The Total should update to reflect the changes

      form display

  9. Additional Display settings in the Formula component make it possible to:
    • Add Prefix text, e.g., $, #, -
    • Add Postfix text, e.g., lb, kg, %.
    • Specify how many digits will be displayed after the decimal point, noting that:
      • Values such as two dollars and fifty cents will be displayed as $2.5
      • Values such as two dollars and seventy-five cents will be displayed as $2.75


references

ADDITIONAL REFERENCES: