Previous | Next | (P-PDF) What's Wrong with my PDF?
Topic: A few different problems
Conf: (P-PDF) What's Wrong with my PDF?, Msg: 140530
From: gkaiseril
Date: 10/5/2005 01:57 AM
>1. The sum from page one is not picking up on page two.
You have to add a calculation for the field to pickup the value from page 1 or place a copy of the field on page 2.
>2. When the form is reset the $0 value remains, which doesn't work if the form is printed and filled out manually.
You are using the built in sum of selected fields to calculate the total. Your total is zero and the built in functions do not suppress the zero result. If you want to suppress the zero result, you need to write a custom calculation script to archive this. A simple document level function could be added to the pdf to perform this calculation. See below.
>3. The first few text boxes on page 2 are not calculating into the sum of the page properly.
Your order for calculation of the form fields needs to be adjusted to the correct order or you could write one calculation script that would do all the extensions and totals. This script could be placed in the grand total field or as a document level script function with a call to the function in the grand total field. If properly constructed this script would only need to be updated when a fields) that is not a simple quantity * price is added.
A document level script to add an array of fields:
function AddArray(aFieldNames)
{
/*
Return the sum of the values of the fields for the field names passed in passed aFieldNames array.
*/
// variable to accumulate sum
var fSum = 0;
// loop through passe field names in passed array
for (i = 0; i < aFieldNames.length; i++)
{
// add only fields with a value not blank
fSum += Number(this.getField(aFieldNames[i]).value);
}
// return sum
return fSum;
}
The page 1 total custom calculation script becomes:
// set field value to sum of array of the following fields
event.value = AddArray (["Text100", "Text103", "Text161", "Text162", "Text163", "Text164", "Text165", "Text166", "Text167", "Text168", "Text169", "Text170", "Text171", "Text172", "Text173", "Text174", "Text176", "Text177", "Text178", "Text179", "Text180", "Text181", "Text182", "Text183", "Text184", "Text185", "Text186", "Text187", "Text188", "Text189", "Text190", "Text191", "Text192", "Text193", "Text194", "Text195", "Text196", "Text197", "Text198", "Text199", "Text200", "Text201", "Text202", "Text203", "Text204", "Text205", "Text206", "Text207", "Text208", "Text209", "Text210", "Text211", "Text212", "Text213", "Text214", "Text215", "Text216", "Text900", "Text98"]);
// suppress zero result
if (event.value == 0) event.value = "";
A similar change would be made to the page 2 total and the total for the beverage order.