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

Another Calculate Tax question

YSquared
Registered: Nov 6 2009
Posts: 6

I've been lurking and searching on this forum for days and can't seem to make my preferred situation work. I'm new to Acrobat forms, but a professional graphic designer.

I can't seem to make a seemingly simple PDF form function work. It's a calculate tax issue. I'm using Acrobat Pro 8 (on a Mac), and have got several Checkbox export values working correctly. They're exported to a "Package subTotal" field, which adds the checkboxes using the Calculate, Value is sum+ in the Text Field Property dialog box. This function is working as expected, but see below for more details.

I then have a "Tax total" field, which uses the Custom Calculation Script (Java) I found on this forum ...

var f = this.getField("Package subTotal");
event.value = Math.round(f.value * 8.25) / 100;

This is calculating the California Sales Tax rate of 8.25% correctly in my "Tax total" field, which is obviously derived from the "Package subTotal" field.

So here's my problem ... not all people who fill out the form are going to be from CA. I'd like the Sales tax to be applied to the "Package subTotal" field only when/if they click the checkbox titled "Sales tax Box." I've spent 3 days experimenting the Actions tab in the Check Box properties, but to no avail.
_________________________________________

Here's my other dilemma. When a patron uses the form there are 3 major options (checkboxes) available to them. These checkboxes all share the same name, but have different export values, allowing only one to be chosen at a time. If their choice is major option 1, there are 2 other sub-options (checkboxes as well) that I've instructed them to choose. If they choose major option 2 or 3 they won't need the sub-options from 1. How do I get it to function so ... if they click on major options 2 or 3 the sub-options from option 1 are not added to the "Package subTotal" field.

Hope this is clear enough. Any help will be appreciated. Thanks in advance

My Product Information:
Acrobat Pro 8.1.7, Macintosh
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
That last bit isn't very clear,
But, for the tax calc you need to do a conditional calculation based on the "Sales Tax Box".
event.value = 0;if(this.getField("Sales Tax Box").isBoxChecked(0))event.value = Math.round(this.getField("Package subTotal").value * 8.25) / 100;

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

YSquared
Registered: Nov 6 2009
Posts: 6
YES! The checked box for the tax calculation works. I've been trying to get this functional for days. Thanks.

On the 2nd problem, and simplifying the question ... When one radio button is activated, I'm trying to get a series of other checkboxes to deactivate and not send their "export values" to a subtotal field.

Presently, I have 3 radio buttons sharing the same name (only one can be chosen, and each has a different export value to the subtotal). I'd like it to function so ... when either of 2 of these radio buttons are chosen, it cancels a series of other checkboxes in the form and their export values to the subtotal.

I'd be happy to email my PDF form to you if that would help.

Again ... thanks for the insights.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
To uncheck a checkbox from a radio button add a mouse up script to the radio button with code similar this this:

this.getField("MyCheckBox").checkThisBox(0,false);

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

YSquared
Registered: Nov 6 2009
Posts: 6
Great ... the code you provided works as planned for one button. How do I add two more buttons? Would this work? ...

this.getField("MyCheckBox") (MyCheckBox.2) (MyCheckbox.3).checkThisBox(0,false);
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
No, that wouldn't work. The line needs to be repeated for each button you want to modify. I'd suggest that you read a bit about JavaScript programming. In fact, using the console window you can test out code directly. Watch the tutorial in my signature block, it will be a big help.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

YSquared
Registered: Nov 6 2009
Posts: 6
Thom - Thanks for the insights, and code offerings. Your website is very helpful.

Repeating the suggested code for each button seemed to get the desired result. There are a few other refinements I could do, but the client seems happy the way the form is with these functions.
candyryan
Registered: Nov 16 2009
Posts: 1
Thanks for the code. The code you provided works as planned for one button.
Thanks you so much.
regards,
candy

_______________
[url=http://simulationpretimmobilier.net]Simulation pret[/url]
garnerjason
Registered: Mar 4 2010
Posts: 6
I am having a similar situation I need some assistance on if it is possible. I am creating a form that will add columns together and then figure sales tax at a rate of 6%. The issue I am having is that some of the accounts are non taxable. I created a check box called "nontaxed" that I would like to have linked to the sales tax so that when it's click there is no sales tax figured. So I know it is something similar to what is here but I can't figure out how to make the box checked function properly when it is not checked. Thank you very much for your time.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Actually is sounds exactly like the question that was asked here. Is this an AcroForm? What is the script you're using now? What are the fields that are involved? And where is the script placed?

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

garnerjason
Registered: Mar 4 2010
Posts: 6
It's very close; however, he was looking to make a check box that when clicked figured tax. I am looking to have the sales tax figured at 6% by default and not figured when the check box is selected. The form is in Adobe Acrobat 9.0 and there is currently no script because nothing I've tried does anything even close to what I wanted done. The script will be placed in the tax field which is currently set as a calculation field. The only fields that are involved, so far as I can tell, are the subtotal, tax, and nontaxed (which is the check box). I figure I need something in the conditional calculation that will say when checked do not figure taxes and when not checked figure taxes at 6%. I know what I need it to do, I just don't know how to make it do it.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
Actually that is the same question, and the solution is exactly the same. Whether the condition is executed when the check box is checked or not is irrelevant. The form of the solution is still the same. You are only talking about a very small variation in the logic of the condition itself.

The bigger question is what kind of form you are using, because that determines the syntax of the script. Did you develop this form in LiveCycle Designer? What have you done so far that does work? for example, do you have code that does the tax calculation without the condition? If so then please provide it.

Thom Parker
The source for PDF Scripting Info
[url=http://www.pdfScripting.com]pdfscripting.com[/url]

The Acrobat JavaScript Reference, Use it Early and Often
[url=http://www.adobe.com/devnet/acrobat/javascript.php]http://www.adobe.com/devnet/acrobat/javascript.php[/url]

Then most important JavaScript Development tool in Acrobat
[url=http://www.pdfscripting.com/public/34.cfm#JSIntro][b]The Console Window (Video tutorial)[/b][/url]
[url=http://www.acrobatusers.com/tutorials/2006/javascript_console][b]The Console Window(article)[/b][/url]

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

garnerjason
Registered: Mar 4 2010
Posts: 6
Okay, I understand you now. Answering the bigger questions. The form was originally created in a free PDF maker I got off the internet (I couldn't afford Adobe's when I first started). I opened the existing form in Acrobat 9 and used the form wizard to create the form fields. The original form field I had was a simple calculation "subtotal * .06". The first script I tried to use was this;

event.value = Math.round(this.getField("subtotal").value * 6) / 100;
if(this.getField("nontaxed").isBoxChecked(0)) event.value = 0;

Not sure if this helps completely, so if you have any other questions I'll try to answer then as well.
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The Calculation is correct for an AcroForm. So you already have your code. if it does not work you need to debug it. Does the script do anything at all? Take a look in the console window and see if any errors are reported.

Thom Parker
The source for PDF Scripting Info
www.pdfscripting.com
Very Important - How to Debug Your Script

garnerjason
Registered: Mar 4 2010
Posts: 6
this.getField("subtotal") has no properties
1:Field:Calculate

That is the message in the debugger. As of now all I get in the tax field is 0. It doesn't appear to be doing anything.
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Check the spelling of the field name and the capitalization. The message is indicating that the field labeled 'subtotal' can not be found.

George Kaiser

garnerjason
Registered: Mar 4 2010
Posts: 6
Okay, wow...now I feel like an idiot. I forgot javascript is case sensitive. I changed "subtotal" to "Subtotal" as I named the field and now it is working. Thank you all for the help.
Jazmine
Registered: Jul 9 2010
Posts: 9
I can't figure out how to calculate tax on Acrobat 9 pro. I have 3 fields that I need to add (PRICE SUBTOTAL; Installation; and DELIVERY) THEN ADD THE 8.250 % TAX, and also I want it to round so that it only has two decimal places. Can someone help me figure this out. I can get it to calculate just the PRICESUBTOTAL tax, but not to add the Installation or Delivery

C. Escalante

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
First, are you using Acrobat form tools to create the form or LiveCycle Designer?

Formating a numeric field usually rounds the displayed result to the appropriate number of decimal places.

How are the instillation and delivery computed or are they user entry?

George Kaiser

Jazmine
Registered: Jul 9 2010
Posts: 9
Im using Acrobat form tools. and the installation and delivery are user entry.

C. Escalante

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
Have you checked the calculation order of the fields?

If you fill in the installation and delivery charges, and then other charges, is the grand total computing? The watch to see if it is computing using previously entered data but not the most recent.

George Kaiser

Jazmine
Registered: Jul 9 2010
Posts: 9
Im not sure.... How do you check the calculation order. Im fairly new to working with acrobat.

C. Escalante

Jazmine
Registered: Jul 9 2010
Posts: 9
Ok... I figured out how to check the calculation order, and i fixed that problem, but it still doesnt calculate the tax. I think it has to do with the javascript that im putting in. I cant figure out what to put in order for the program to calculate the 8.250% tax

C. Escalante

gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4307
What code?

How are you trying to calculate the tax? There are 3 options on the calculate tab, please specify which option you are using.

There are also tutorials, articles, and eSeminars on demand about creating forms with calculations.

George Kaiser