How to Fix Acrobat JavaScript Field Multiplication Formula
Question details
The user needs to correct an error in an Acrobat calculated field where a formula fails to multiply values correctly.

- Product
- Adobe Acrobat
- Device & OS
- not provided
- Scenario
- Setting up a custom calculated field in a PDF form to multiply two variables, such as hours by a pay rate.
- Observed behavior
- The calculation fails or returns an error because the script uses the letter 'x' instead of a valid JavaScript mathematical operator for multiplication.
Ensure your PDF form is opened in editing mode and double-check that the exact field names used in your document match the ones referenced in your script.
Replace 'x' with the JavaScript Asterisk (*) Operator
Correct the mathematical syntax in your PDF's calculation script by replacing the letter 'x' with the asterisk symbol (*).
JavaScript requires specific operators for mathematical calculations. The letter 'x' is treated as standard text or a variable name, whereas the asterisk (*) functions as the official multiplication operator. Without this correction, the formula will break.
Right-click the calculated field in your PDF form (e.g., the total pay field) and select Properties from the context menu.
Navigate to the 'Calculate' tab. Select the 'Custom calculation script' option and click the 'Edit' button.
Locate the multiplication section of your code. Change the letter 'x' to the asterisk '*'. For example: event.value = Number(this.getField('Hours1').valueAsString) * Number(this.getField('Pay Rate1').valueAsString);
Click OK to save the script and close the Properties window. Enter test data into the 'Hours1' and 'Pay Rate1' fields to confirm the calculation now works properly.

Edit PDF Form Fields and Calculations in WPS Office
WPS Office offers a comprehensive PDF editor that allows you to easily create, modify, and fill interactive form fields without getting bogged down in complex script debugging.
- 1. Open your PDF form in WPS Office: Launch WPS Office and open the PDF document containing your form fields.
- 2. Access Form Editing Mode: Navigate to the 'Form' tab on the top ribbon and select 'Edit Form' to interact with all available fields.
- 3. Modify Field Properties: Double-click on any calculation field to open its properties menu, where you can easily update formulas, change field names, or adjust formatting.

Frequently Asked Questions
Why isn't my PDF custom calculation script working?
Common reasons include syntax errors (such as using 'x' instead of '*'), mismatched field names (JavaScript is case-sensitive), or the referenced fields containing text instead of numerical values.
What is the correct JavaScript operator for division in a PDF form?
For division, you must use the forward slash (/) operator instead of a standard division symbol. For instance, use: fieldA / fieldB.
Do I need programming skills to create calculated fields in PDFs?
Basic calculations like sum, product, and average can often be done using built-in calculation options in most PDF editors. However, complex logic requiring conditional statements relies on custom JavaScript.




