How to create forms that perform simple mathematical calculations

how-to-create-forms-that-perform-simple-mathematical-calculations-blog-image

Wouldn’t it be great if that sales form you just created could calculate items like product costs or discounts, and add the right amount of tax?

If you’re using Foxit PhantomPDF, you can do exactly that. Not only is PhantomPDF extremely useful for form filling and form design, it enables you to set properties that apply formatting, determine the appearance and actions, perform mathematical operations, and so forth.

To perform simple mathematical calculations in your form, you’ll want to use the text field.

Using the Text Field to create a simple mathematical form

A text field is a commonly used form object. Normally, you can type any value into the text field. However, using Foxit PhantomPDF, you can apply text formatting or even calculate the value of a text field using other form fields.

How a text field behaves is determined by settings in the Text Field Properties.

The text field has a General tab, an Appearance tab, a Position tab, an Options tab, a Format tab, a Validate tab, a Calculate tab, and an Actions tab.

How to create a simple mathematical form - 1

To create a simple mathematical form, you’ll use the Calculate tab for the text field properties.

With this option, you can perform mathematical operations on existing form field entries and display the result. You’re also presented with the following options, which you can choose as you see fit to make your form behave the way you want it to:

    • Choose “Value is not calculated” if you want the users to enter the value manually.
    • Select “Value is the” and then choose one of the following options:
      1. Choose Sum to add the values entered in the selected fields; choose Product to multiply them; or choose Average, Minimum, or Maximum to combine other fields.
      2. Select Pick to open a Field Selection dialog box with a list of the available fields in the form that you select to add or deselect to remove from the calculation.
    • Select “Simplified field notation” to enable simplified JavaScript with field names and simple arithmetic signs. Click the Edit button to open a JavaScript Editing dialog box in which you can write, edit, and add scripts.
    • Use “Custom calculation script” to display any custom JavaScript script to calculate the value of the field. Click the Edit button to open a JavaScript Editing dialog box in which you can write and add new scripts.

Set text field properties as default

After setting text field properties for a new text field, you can set your settings as the new default for all the text fields you create in future. That’s a time-saving feature if you’re planning to create similar forms again.

To set the current properties as default, right-click the text field > select Use Current Properties as New Defaults.

That’s all there is to it. So the next time you need a simple form that can do simple mathematical functions for your users, try the Text Field.

Leave a Reply

Your email address will not be published. Required fields are marked *