Copy link to clipboard
Copied
Hello, I have an excel spreadsheet that I have turned into a form with Adobe Acrobat Pro that has a qty field, a price field and a total field, among others. I have set the total field to automatically calculate to the product of the Qty field and price field, which works fine. The issue is that by default it displays a zero (or actually, $0.00, since I have it formatted to price), and so if people print out the form to fill it out manually, they have to cross out the zero.
Is custom javascript the only way to get the field to be conditionally hidden or non-printable? If not, can you tell me a better method? If so, can you point me to an example of this that works? I can provide screenshots if necessary.
Copy link to clipboard
Copied
As the custom validation script of the field enter this:
if (event.value==0) event.value = "";
Copy link to clipboard
Copied
As the custom validation script of the field enter this:
if (event.value==0) event.value = "";
Copy link to clipboard
Copied
PS. In the future you'll be better off posting questions about Acrobat in the Acrobat forums, like this one: PDF Forms
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I cannot get any of these formulas to work. The 0 still shows up no matter what. I've removed the currency symbol and still have the issue
Copy link to clipboard
Copied
Post an example PDF of your attempt to get this to work.
Copy link to clipboard
Copied
So I finally got it working. Pretty ridiculous but if you put the calculation in before adding the script it will not work. I had to add the script first, and then the formula and then the format for $. Any other order results in the 0 showing on the form.
Copy link to clipboard
Copied
So did you read the posted article? It is not a good idea to use both built in formatting and a script to adjust formatting. But if you do not provide us with the details of what you are trying to do we can not help you to do it correctly. And it does not seem you are doing it correctly, which can lead to undesired results.
Copy link to clipboard
Copied
Ok I see that now. I had it working but now when I type anything into an unrelated field, it changes all 8 calculated cells to $0.00
How would you suggest to make a formula for my total cost cell. Basically it is a quote form, and the final text field in each row is a calculated product of two other cells. I want it to show the $ and two decimal places but I also want it to remain blank if the value is $0.00. The quote form is 8 rows, but if you just put values in the first row and print it, everything else remains blank.
Copy link to clipboard
Copied
So first, read this article:
https://www.pdfscripting.com/public/How-to-set-000-value-to-blank.cfm
Use the Format script example for your form.
If there are still issues, post your form with the code you think should be working and we'll take a look at it.
Copy link to clipboard
Copied
This isn't working for me. I also have my field formatted to dollar figure. My field's name is ClosingBalance.
I'm inserting
if (event.value==0) event.value = "";
in the "Run custom validation script" box.
Copy link to clipboard
Copied
Post your question to a new thread
Copy link to clipboard
Copied
Were you able to get the custom validation script to work with the field being formated with the currency symbol ($0.00)? I am having the same trouble. I can get it to work if I remove the currency symbol. I don't know much about JavaScript.
Does something else need to be included in the script?
Copy link to clipboard
Copied
Do you have a default value set as 0 for the field? That was my issue.
Copy link to clipboard
Copied
I do not. The only properties I have are:
Custom validation script, if (event.value==0) event.value="";
Calculation is product of, QTY Row 1, UNIT PRICE R1
The custom validation script will work as long as I change the currency symbol to NONE, but really need this column to be a currency and not just numeric with decimal.
Copy link to clipboard
Copied
So on my Options tab, there is Default Value. Make sure there's no value in there.
The rest "should" work. Decimal places 2, currency symbol.
Copy link to clipboard
Copied
This is close to the problem I'm having. I have estimated days of inventory on hand (Text53) as a calculation. Quantity on Hand (Text52) divided by Daily Usage (Text51). So in the simplified field notation I have: Text52/Text51. Only problem is I get errors when I set properties on Text53 to number. I get Java errors. (The Value entered does not match the format of the field [ Text53] So I leave it at none but then it keeps putting NaN in the cell if a number was entered and then cleared. When I clear the form the NaN stays there. I'd like it to go to blank if anything or 0.
Copy link to clipboard
Copied
You will get NaN when you divide by zero.
Copy link to clipboard
Copied
So how do you get it display blank instead of NaN?
Copy link to clipboard
Copied
Use Javascript for the calculation.
Copy link to clipboard
Copied
Thank you. I'm still unclear. In the Calculate form properties? Currently is is in simplified field notation: Text52/Text 51. You are saying to use the custom calculation script instead? And what would that Java look like?
Copy link to clipboard
Copied
First, you've written that the name of the divisor field is "Text 51". Is this correct? if it is, then the simplified field notation will not work as written anyway. It doesn't like spaces in field name.
Here's a calculation script that sets the field to blank if
var nDivisor = Number(this.getField("Text 51").value);
if(nDivisor == 0)
event.value = "";
else
event.value = this.getField("Text 52").value/nDivisor;
Copy link to clipboard
Copied
Here's an article that discusses this topic in detail:
https://www.pdfscripting.com/public/How-to-set-000-value-to-blank.cfm
Copy link to clipboard
Copied
Type this script into the DEFAULT VALUE box on the OPTION tab (not the RUN CUSTOM VALIDATION SCRIPT on the VALIDATE tab) . This fixed the issue for me.
if (event.value==0) event.value = ""
Copy link to clipboard
Copied
That is not possible. You must have a script somewhere else that works for you.