I have created a form, with the calculated fields set to read only, and with a validation script of
if (event.value == 0) event.value = '';
(so that the calculated fields do not display as $0.00)
All but four of the calculated fields are named Item.0, Item.1 etc., plus there are SubTotal, ShippingCharge, CCFee and Total fields that need to stay blank until data is entered into the form.
Initially, I tried to add the script as a document level script, but it didn't work and I'm thinking it needs more to the script to use at the document level, but I have no idea what more it needs.
Where did I go wrong? It certainly would be quicker to add calculated fields if I didn't have to add that validation script to each.
Even with a document level script you would need to call it in every calculated field.
I you were to write "app.alert("Hello World");" as a document level function, it would only execute when the PDF was initialized or opened and not again as long as the PDF remained open.
If you rote a document level function using JavaScript like:
function Hello() {
appp.alert"Hello World, I am a function");
return true;
}
It would never run until called with a JavaScript statement like "Hello();"
So even with a document level script and preferably a function, you still would need to edit every calculation to call the function or the script would never run.
You could also create a document level function to suppress the zero display and then write more code to add the call to this function to the calculated fields.
You need to learn more about the scope of items, how events are processed within a PDF, what functions are and how to use them effectively. You might want to start with getting or linking to a copy the Acrobat JS API Reference.
North America
Europe, Middle East and Africa
Asia Pacific