These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

can calculated fields be set to NOT display if zero?

masada
Registered: Jul 31 2007
Posts: 4

This is a useful function, available in Excel spreadsheets, for example. Greatly reduces visual clutter. And if zeros show up in a field before a user fills it in, it can be a bit off-putting.

I suspect the function could be implemented somehow in JavaScript, but I was hoping that someone had an easier or more general answer that I could use, a check box or preference item that would make things work would be ideal.

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
For Acrobat Forms, not LiveCycle Designer, one can use the following JavaScript code as a custom validation script for the calculated field:

if (event.value == 0) event.value = "";

This code should work for the various calculation methods. Of course if you used the "Custom calculation script", you could place this code at the end of the script.

George Kaiser

masada
Registered: Jul 31 2007
Posts: 4
Thanks for your help.
However, I ran into a problem with that solution. If I were to use that script within the custom calculation script section it erases any code in the top box marked "Value is the ____ of the following fields." Is there a way I can use both or someway I can make the two compatible with one another?
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Since you were not using the "Custom calculation script" you can not add the code there. The selection of the calculation method on the calculation tab from the listed options are mutually exclusive. Since you have chosen the first option, you must put the code in the "Custom validation" of the "Validation tab.

George Kaiser

pflores@sunflow...
Registered: Aug 21 2007
Posts: 37
I'm working in Livecycle 8. Example: Field 3 is the product of Field 1 & Field 2. However, if there is no data in either Field 1 or 2, I don't want anything in Field 3.
I already have the script for the calculation, just needing to know what to add at the end to have a blank field. Thanks.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
A sample script can be found Stefan Cameron on Forms, http://forms.stefcameron.com/ , in the blog post Calculate Scripts, http://forms.stefcameron.com/2006/05/15/calculate-scripts/ . You will have to modify the logical statement for the if statement to test the 2 input fields rather then just 1 field.

George Kaiser