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

Total of a sum to return a blank value rather than zero

Timmyb
Registered: Nov 19 2007
Posts: 25

Hi

Quite an easy one I hope. Have done a search but the examples I have found do not quite fit.

I am using Acrobat 7 Pro (MAC). I have a calculation which adds up 11 boxes. I would like the total box to show a blank entry rather than the zero if no amounts are entered.

Can someone show me how? I understand that the whole calculation will need to be scripted including the sum itself.

Please assume basic scripting skills in your reply.

Thanks
Tim

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Are you creating your form using Acrobat Forms or LiveCycle Designer?

If you are using Acrobat Forms, you can use the following JavaScript as a custom validation script for the sum field:

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

This will always supress the dispaly of zero.

Have you read Ted Padova's 101 Tips and comments?

If you have used LiveCycle Designer, you can set the presence property for the result field.

if (NumericField1 > 0) then
$.presence = "visible";
NumericField1 * 10;
else
$.presence = "invisible";
0;
endif

http://forms.stefcameron.com/2006/05/15/calculate-scripts/

George Kaiser

Timmyb
Registered: Nov 19 2007
Posts: 25
Hi

Thanks for this. I am using Acrobat Forms.

I put your code in the custom validation script for the sum field and this has not worked?

Should it be in the custom calculation script instead? If so, how do I manually script the sum and your code?

Thanks
Tim
Timmyb
Registered: Nov 19 2007
Posts: 25
Hi

Got it to work now!

Thanks
Tim
MardellRyan
Registered: Jan 21 2008
Posts: 3
Hi! I'm having the same problem, but since the resolution for this was not posted, I'm not sure how to enter. I have a list of subtotals (7 possible subtotals) and then need the grand total, but would like without the $0.00 showing. I'm using Acrobat 9 pro (Acrobat Forms). Thanks!
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Carefully read my post, I have included the code for both Acrobat and LiveCycle Designer forms.

Your situation is different because you are not displaying a pure numeric value but a formatted string value. If you remove the currency format, then the code will work.

If you need to use the currency symbols you will need to the necessary code to change the displayed format to exclude the currency symbol. Searcg for "AFNubmer_Format"

Setting number format to a text field..
A sample script:

if(event.value == 0 | event.valueAsString == "") {
event.value = "";
AFNumber_Format(2, 0, 0, 0, "", false);
} else {
AFNumber_Format(2, 0, 0, 0, "$", true);
}

George Kaiser

MardellRyan
Registered: Jan 21 2008
Posts: 3
Hi George,

Thanks so much for your reply. I wasn't quite sure how to execute your code, but your tip on removing the currency format helped a lot.

I found another post on an Adobe forum with instructions to use simple calculations in conjunction with a custom validation code.

This string in the subtotal columns: if(event.value == 0 | event.value == '') event.value = '';
This string in the grand total field: if (event.value == 0) event.value = "";


As you stated, it didn't work with the dollar sign in the grand total field, but once removed everything is working fine now.

Thanks! I really appreciate your time.
MardellRyan
Registered: Jan 21 2008
Posts: 3
Hi Again George!

It took me longer for your explanation to sink in since I'm not a programmer, but realized exactly what you were describing so ended up using your script and everything is working great!

Thanks again for your help!


pakong
Registered: May 22 2008
Posts: 1
Hi George,
I'm new to this and I'm using LCD 8.1. I would like to know how you set the Presence field using the code you gave. In the object palette, the presence can only be selected not manipulated.

Thanks
Paul
start
Registered: Apr 21 2011
Posts: 2
你好

网站托管的
start
Registered: Apr 21 2011
Posts: 2
你好

<网址=“htt​​p://www.crocodilenetworks.com
“>的VPS