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!!!
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.
Copy link to clipboard
Copied
A good place to start learning how to do this are these tutorials:
https://acrobatusers.com/tutorials/how-to-do-not-so-simple-form-calculations
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....
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.
Copy link to clipboard
Copied
Oh! Ok. I had no idea. Sorry.
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!
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.
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.
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.
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.
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.
Copy link to clipboard
Copied
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!