HomeUsing FormSpringBuilding FormsSelf-Calculating Form Fields

2.12. Self-Calculating Form Fields

Self-calculating form fields are handy for order forms or anywhere that you might need to compute a value based on what users select on your form.

To create a calculating form field, first create a Short Answer or Number field, then look for the Use Calculation link underneath the Default Value area.  Click on that link, and you will see a calculator that you can use to setup the calculation.

Select a field from your form and use the operator buttons to the right in order to create an equation.  For example, assuming you have fields Product A and Product B on your form that users can opt to purchase, and a third field Quantity, the following will be an appropriate calculation for the Amount field:

( [Product_A] + [Product_B] ) * [Quantity]

Using Separate Values

When using select lists, checkboxes and radio buttons, you can check the box that says "Use separate values".  This allows you to add a number or text value to each option in the field.  This can be used in many different ways, but here is one example:

Say you wanted an order form where mail orders were charged $5 shipping and pickup orders were free.  You could add a radio button field called Shipping to your form with two options, mail and pickup. Click on the check box that says "Use separate values" and assign a number value to each option, i.e. $5 for mail and $0 for pickup. Use a self-calculating form field to generate your total cost for the form and plug the Shipping field result into that algorithm, i.e. (Product A * Quantity) + Shipping to get the total amount you are charging the customer.

Note:  You will see an error when using option values that are the same, such as setting two different items as both being $5.  This is because option values must be unique.  To get around this, you can set one item to $5, one to $5.0, one to $5.00, etc.  While these are all technically the same number, 5, the form builder sees them as unique values and will allow you to use them.

This page was: Helpful | Not Helpful