I have set up some basic formulas in my PDF. Example....I have a Swing field and a Cycles field. In the Cycles field under calculate I have a Simplified field notation: (60*60)/Swing The formula works fine but I have to have a number in Swing or it gives me a The value entered does not match the format of the field [Cycles] - the format in Cycles is set up as a Number. What do I need to change to be able to have a blank in Swing?

When there is no value in the "Swing" field, the value returned for an empty string is 0, which means you are dividing by zero - which results in "NaN" - or "Not a Number". This is - as the name suggests - not a number, and therefore does not fit into the number format that you associated with the field. There are two ways around this: You can either use a custom formatting script for your result field, or you can use a custom calculation script that will not perform the calculation when there is no valid number in the "Swing" field. I would go with the second route. Something like this should work:

I think I'm finding my problem. I am very inexperienced in JavaScript. What I have done is convert an excel file to PDF and am trying to program 3 fields. The first field will be filled in by the user with a number (however I want it blank to start). I've labeled that Swing. That will then calculate Cycles (60*60)/Swing. The next field they will enter is labeled Bucket. The field I call Maximum will calculate Cycles*Bucket. Finally They will enter Volume in one field (named Volume) and Hours into another field (named Hours) The final box is Efficiency, which calculates the total of Volume/Hours/Maximum. I'm thinking I will need to write a custom calculation script for all 3 boxes or they will be off. I plan to convert several things from excel to fillable pdf's and will need to learn how this works. Is there a course you recommend? Any help you can offer would be greatly appreciated for this form. I have all the formula's working fine..but just can't clear all the boxes to start with a blank form.

JavaScript for Acrobat is not the same as JavaScript for the web - that makes it a bit harder to find a good resource. Take a look here for a book that is dedicated to Acrobat's JavaScript: Beginning JavaScript for Adobe Acrobat

The final box I am trying to write code in is labeled efficiency. That needs to calculate 2 fields that are entered by the user. One field is called Volume, one is called Hours. Efficiency is calculating the value of Volume divided by Hours divided by the field we got from the first code called Maximum.

I was trying to play with the previous code...but know I'm not doing it properly. Any help is very much appreciated! =)

Then you can use the variables volume, hours and maximum in your calculation:

event.value = volume / hours / maximum;

Do yourself a favor and read up on the syntax of JavaScript, it will make your life much easier if you know what is valid and what will cause errors - and if something does report an error, you might be able to figure out why it's complaining about a certain construct. You cannot copy and paste your way to a successful solution. You need to be able to understand what the code snippets you find online are actually doing so that you can adjust them to your specific needs - or fix something half a year down the line when the requirements change.

Thank you again for helping! I will definitely read up on the syntax of JavaScript. I am now able to clear the fields without error codes...however, my formula is not working properly. My Cycles and Maximum are computing properly...but Efficiency is not doing any calculations. I am missing something.

When you call this.getField("Some Field Name"), this method will return a field object. Such a field object has a number of properties, and some methods (what exactly that means will become clearer once you get a better understanding of JavaScript). For now, let's take a look two of these properties: "value" and "valueAsString" - the first one will interpret the value based on the context you are calling it from and will either return a number or a string (at least in your example). The latter one will always return the value as a string. You are setting your "Volume", "Hours" and "Maximum" variables to the value property of the field, however, further down you are trying to at the "valueAsString" property from your variable e.g. "Volume". At this point, it's not a field object, it's a number or a string and does not have a "valueAsString" property. Also, JavaScript is case sensitive, so "volume" is different from "Volume".

Thank you both! Karl, I still kept getting an error with yours (but the figures worked great!) however Try67's worked for me. I can't thank you both enough! You both are pro's at this. I'm hoping to learn as much as I can.

I have one final PDF that I'm working on and have figured out pretty much the whole thing. It is very similar to the first one that now works perfectly.

My second one has almost the same format....3 boxes that are programmable based off entries. I know I have the first box called Maximum computed properly. My second box however is where I KNOW I need to put in JavaScript but I believe I am messing up on the formula. This field takes the value of Maximum and multiplies that by the amount the user enters into Bucket then it divides that by what the user enters into Depth multiplied by Width and divides that total by 27. example: (Maximum*Bucket) / ((Depth*Width)/27)

I hadn't even noticed I'd done that! And that did make a huge difference. Thanks again for all your tips and help! I actually understand a lot more now! I have a lot to learn! Have a great afternoon!!!

Thank you! I fixed the code with your advice. How long have you been writing code? How did you learn? Again, Thank you for your help with this! I'm interested in learning more. We have several excel programs that would work better in Adobe.

I've been writing code for Acrobat for more than a decade now, and code in general about twice that.

I taught myself JavaScript for Acrobat (and other Adobe applications), by trial and error, by following the good advice given by experts on these forums (and others, now mostly defunct), as well as by reading the API and parts of the PDF Specifications.

I have the PDF's calculating fine. We sent them out to the guys on the field, they all have IPADS....and they can not get it to work. I have tried downloading Adobe...and it will now let me fill in the fillable fields..but the calculations will not work. What program can we use to have the calculations work on Ipads?

As try67 said, there are 3rd party PDF viewers that have more support for custom calculations than Adobe's mobile Reader. Designing a form and then trying to find a mobile PDF viewer is the wrong order: You need to first pick what PDF viewers you want to support (e.g. on desktop, iOS and Android platforms), and then design your form so that it only uses the subset of features that are supported by all viewers.

I need help with a code as well. I form PDF that has many fields to fill in but to feels that have current monthly salary (CMS) and new monthly salary (NMS) but i need to know what the percent increase it would be. I have this basic javascripts (NMS-CMS)/CMS its me the total percent. But if I enter something first I get this message first: The value entered does not match the format of the field. Please help me that I don't get this message first before I start typing something else before putting the salary information.

The code help me what I needed but i am across this problem. How would I fix this?

If I enter current monthly salary (CMS) of $6,000.00 and there was no change to monthly salary but I wanted to leave New monthly salary (NMS) blank or put 0.00 in the field the percent box gives me -100.0%. (first screen shot)

If i do it the opposite way and do $6,000.00 in new monthly salary (NMS) and put a blank field or 0.00 in the current monthly salary (CMS) I get 0.00%. (second screen shot) How can I get this to happen with the other problem.

I still like the current code because it is giving me the percentage of what I need as you can see in 3rd screen shot.