• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

Custom Calculation Help Needed

New Here ,
Sep 26, 2018 Sep 26, 2018

Copy link to clipboard

Copied

I could use a little help (or a lot...), please. I've got a calculation on a membership dues form that has totally taxed my brain. I will be adding an image, also. Hopefully, with everything I have included, someone can help me out.

I'm creating a membership dues form for members of a trade association. We are small and don't really have a need or the ability to invest elaborate dues remittance systems. What we are trying to do is create a form that self calculates, so all they have to do is return the form with their check or go to PayPal to send in their dues. I've been able to calculate all the fields but one. It is a multi step one that requires us to use the same base number in more than one calculation.

So, my field names are:

Total Usage

A

B

C

Dues

(I plan to hide A, B & C, so I went simple. )

What I need to develop is a final number for dues when:

 $10 for each usage up to 50

 $5 for each usage over 50

 $350 minimum dues

I set it up so:

A would = the $10 calculation

B would = the $5 calculation

C would = A+B

D would determine the total or apply the minimum.

I am also totally open to any better method someone can offer!

Thank you!!!

Calculation Needed.png

TOPICS
Acrobat SDK and JavaScript , Windows

Views

232

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Sep 27, 2018 Sep 27, 2018

You need to write your code very carefully. For example, it's getField, not getfield. JavaScript is case-sensitive so only the former will work.

Another important thing is to use the JS Console (see also: https://acrobatusers.com/tutorials/javascript_console) and to keep an eye out for any error messages in it when you write or use your code, as it will provide valuable information about what went wrong.

Likes

Translate

Translate
Community Expert ,
Sep 27, 2018 Sep 27, 2018

Copy link to clipboard

Copied

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 27, 2018 Sep 27, 2018

Copy link to clipboard

Copied

Thanks you. I'll watch these. I was able to do the rest of the calculations using tutorials, but I just got overwhelmed in this one. Hopefully these help me some. I will say...the titles look familiar, and I'm thinking I've already been there....

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 27, 2018 Sep 27, 2018

Copy link to clipboard

Copied

If you have a specific question feel free to post it. If you want someone to do the entire thing for you it will usually be for a price.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 27, 2018 Sep 27, 2018

Copy link to clipboard

Copied

Oh! Ok. I had no idea. Sorry.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 27, 2018 Sep 27, 2018

Copy link to clipboard

Copied

Should I delete the post? I didn't mean to do something inappropriate. I thought the community was to get help with what I couldn't figure out. So very sorry!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 27, 2018 Sep 27, 2018

Copy link to clipboard

Copied

No, no, not at all. As I said, if after you've read the tutorials you still have questions we'll be happy to answer them.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 27, 2018 Sep 27, 2018

Copy link to clipboard

Copied

Ok. Whew! So when I get back to my computer this afternoon, if I still can't make it work, I should post the actual script I wrote- that doesn't work- and y'all could help me figure out where I went wrong? I feel like where I got totally messed up was in the whole this.getfield process more than the calculation functions. That's the stuff that makes no sense to me. The math part of it makes perfect sense. I want it to work more like Excel.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 27, 2018 Sep 27, 2018

Copy link to clipboard

Copied

You need to write your code very carefully. For example, it's getField, not getfield. JavaScript is case-sensitive so only the former will work.

Another important thing is to use the JS Console (see also: https://acrobatusers.com/tutorials/javascript_console) and to keep an eye out for any error messages in it when you write or use your code, as it will provide valuable information about what went wrong.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 27, 2018 Sep 27, 2018

Copy link to clipboard

Copied

For this it will be important to get the field calculation order set correctly. Some people confuse this with the tab order, which is something entirely different. Exactly how you set it depends on which version of Acrobat you're using, and it can be hard to find, so post again if you need help with setting it.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 27, 2018 Sep 27, 2018

Copy link to clipboard

Copied

In cases where calculation order is important, I find it's best not to put the calculations in the fields themselves. Instead, create a hidden calculated field which performs all of the necessary calculations and in the order you require them. That way, you're only debugging your calculations and not constantly checking that Acrobat decided to change the order when you edit field properties or add and remove fields.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 07, 2018 Oct 07, 2018

Copy link to clipboard

Copied

LATEST

Thank you to every single one of you for your replies!! Each of these did help me some - mostly for answers to future questions that I would have run into soon.

I'm marking "try67" as having given me the correct answer, because it was the debugger that helped me. (AND can I just add as an aside!? THAT feature should be turned on automatically!)

Now for what actually worked in case some poor soul (like me) runs across this post and wants an answer. My statements were correct. My spelling, etc...all correct. I was even actually using "getField" rather than "getfield.") Everything I had input matched an example from somewhere else.

BUT, so I could see what I was doing, I was drafting in Word...then copying and pasting into JS Editor. What debugger finally told me that nothing else helped with was that when I pasted my work, it was formatting the quotes so they were showing slanted in the Editor instead of perfectly vertical. Inside the Editor itself, I deleted the slanted " and replaced with the vertical ". It worked in every single non working calculation!!!

I'm telling y'all this, because I made the replacements as a lark, and I kid you not I was blown away when it worked. This had hung me up since July. I walked away from it then and just about every other week played with it. I was literally at my wit's end when I got brave enough to post for help!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines