Form properties: Calculate
The Calculate properties are specific to the Text Box and Dropdown fields. They enable a field to be calculated based on the contents of other fields in the document. The calculation is invoked whenever the value of the appropriate fields change.
Value Is Not Calculated: This is the default calculation type. No calculations will be made.
Calculation Field: Select this option to make simple calculations based on the contents of the other fields in the PDF.
- Sum (+): Sums the selected fields.
- Product (x): Mulitples the selected fields.
- Average: Takes the average of the selected fields.
- Minimum: Takes the smallest value of all the selected fields.
- Maximum: Takes the largest value of all the selected fields.
Simplified Field Notation: Specify the Simplified Field Notation to make more complicated arithmetic calculations. The following is an example of a Simplified Field Notation calculation where a result is being calculated for the "ResultsTextBox" form field from values found in other fields on the form:
ResultsTextBox = AverageEmployeeSalaryTextBox * NumberOfEmployeesTextBox + TotalEmployeeBonusTextBox -TotalTaxesTextBox
Ultimately, names used in the simplified field notation are replaced with the equivalent JavaScript calculation. For example, this example gets translated into the following JavaScript:
this.getField("ResultsTextBox").value = this.getField("AverageEmployeeSalaryTextBox").value * this.getField("NumberOfEmployeesTextBox").value + this.getField("TotalEmployeeBonusTextBox").value - this.getField("TotalTaxesTextBox").value
Custom Calculation Field: Use this field to specify a Custom Calculation Field using JavaScript. For example, a form may be created letting the user input the amplitude, period, phase shift, vertical shift, and x-coordinate for a sine wave, a Custom Calculation Field might look like:
var amplitude = new Number(this.getField("AmplitudeTextBox").value);
var period = new Number(this.getField("PeriodTextBox").value);
var phaseShift = new Number(this.getField("PhaseShiftTextBox").value);
var verticalShift = new Number(this.getField("VerticalShiftTextBox").value);
var x = new Number(this.getField("XTextBox").value);
event.value = verticalShift + amplitude * Math.sin(period * x + phaseShift);
