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

Calculating Tax Depending on the State.

DannyRoberts
Registered: Jul 31 2008
Posts: 10

Hi, I am fairly new to building forms in acrobat. I've made an order form for my company, and right now i have a few calculation forms.
the first row has a field (Subtotal1) represents the initial purchase Price which is $149. The second row has a field (AddLicenses) for entering how many additional licenses a person wants, and then a field (Subtotal2) on that row which is formated to Calculate the number of addition licenses multiplied by the price of additional licenses (AddLicenses * 99). Ok so where my question comes in....
i've been trying for two days to figure out, how to write a script or even set up the form, where my Combo box, of the states initials, is linked to the Sales Tax box(Tax).
I want to have the form set up where, if the State Combo Box on "CA" then it will
Add Subtotal1 and Subtotal2 and then multiple it by 0.0775 and put's the answer into the tax box, and if any other state is selected $0.00 is put into the Tax box. I'm a complete beginner when it comes to scripting, so if you could help me with this i would love it!

My Product Information:
Acrobat Pro 8.0, Macintosh
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
Because each export value for a drop down list or combo box must be unique one might not be able to use the sales tax rate as the export value, so you will need to get the sales tax rate through the use of "if()" statements or the 'switch()" statement.

Since there is only a California sales tax why not just use a check box?

Are you expecting a the overturning of Quill vs North Dakota or neighboring states to form a tax collection consortium?

For using the switch statement, which will allow for easily adding code by each state needed:

var fTaxRate; // variable for tax rateswitch(this.getField("cbState').value {case 'CA': // California

fTaxRate = 0.0775; // tax rate for this state

break; // skip the rest of the test

 case 'AZ': // Arizona

case 'NV': // Nevada

case 'OR': // Oregon

default: // all other states

fTaxRate = 0;

) // end switch

 // compute tax rate times the sum of subtotal 1 and subtotal 2event.value = fTaxRate * (this.getField('SubTotal1').value + this.getField('SubTotal2').value);

George Kaiser

DannyRoberts
Registered: Jul 31 2008
Posts: 10
That you so much for your quick responce! to answer your questions...
About doing a check box, is it easier doing it that way? i could do it that way if it is easier. To answer your other question, not really sure, what i do know is we just charge our sales tax to Californians.

and i have one more question, as i said i'm a rookie at scripting, not really sure where i should put the code you wrote? Also not sure how to set up export value in the combo box... do i put the initials in the item box and the typed out state in the export box? sorry if this is a silly question.
thanks so much your a life saver.
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
Using a check box would just requiring checking to see if it is checked but if one has to update for changes in the state sales tax collection process, a drop down box would require just changing the code and not redoing a form field.

The script is the "Custom calculation script" for the sales tax field.

George Kaiser

DannyRoberts
Registered: Jul 31 2008
Posts: 10
Thank you, when i put the script into the "Custom calculation script" for the sales tax field. i got and error

"SyntaxError: unterminated string literal 2: at line 3"
and it is high lighting "case 'CA': // California"
not sure what to do.
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
Sorry, I typed the code without testing it. The script should be:
var fTaxRate; // variable for tax rateswitch(this.getField('cbState').value) {case 'CA': // CaliforniafTaxRate = 0.0775; // tax rate for this statebreak; // skip the rest of the test case 'AZ': // Arizonacase 'NV': // Nevadacase 'OR': // Oregondefault: // all other statesfTaxRate = 0;} // end switch // compute tax rate times the sum of subtotal 1 and subtotal 2event.value = fTaxRate * (this.getField('SubTotal1').value + this.getField('SubTotal2').value);

George Kaiser

DannyRoberts
Registered: Jul 31 2008
Posts: 10
thanks again, but for some reason it's not working still. nothing is happening.
I clicked on the JavaScript Debugger it says

TypeError: this.getField("cbState") has no properties
2:Field:Calculate

not sure what to do...
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
That's just some sample code that assumes there is a field named "cbState" that is the combo box containing the list of states. So, you'd replace "cbState" with the name of your combo box that contains the list of states.

George
DannyRoberts
Registered: Jul 31 2008
Posts: 10
Oh yes!
thank you thank you!
it's all working.
thanks so much.