Tech Tip: Performing Basic Field Calculations in Laserfiche Forms
By: Eric Cressey
When users fill out forms, like purchase orders or expense reports, they often expect those forms to perform calculations based on the information they enter. You can use JavaScript to modify a Laserfiche form’s behavior to perform these calculations.
If you’ve never used JavaScript before, don’t worry. The online help for Laserfiche Forms contains JavaScript code for commonly requested form calculations, like those in purchase orders and expense reports.
Here’s the best part: you don’t need to know JavaScript to use the code in the help files! Simply add CSS classes to the appropriate fields and insert the JavaScript into the form’s Script page.
The online help includes JavaScript code for:
- Adding fields together and populating another field with their sum
- Calculating item subtotal based on quantity and price (Purchase Order example)
- Calculating the subtotal for table rows and populating another field with the total
- Calculating the total for table columns
- Calculating the subtotal of fields within a repeatable collection
- Populating a field with radio button or checkbox values
The code provided for each of these calculations does not need any modification. Note that the examples for tables and repeatable collections work for one table or collection; if you need to perform calculations on multiple tables or collections, some modification will be necessary.