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

IF THEN tax calculator

AndresMtl
Registered: Apr 15 2010
Posts: 3

I have an order form with a ComboBox with various Canadian provinces called "ComboBox2". Each province has a different tax rate. (For example, ON is 8%, QC is 7.5%, NS is 15%)

I then have a subtotal Field named "Subtotal".

The last field is a taxes calculator Field named "Taxes".

What I want is for the "Taxes" field to change the rate depending on what province was chosen from "ComboBox2".

This is the code I have so far, which seems logical, but is not working:

var a = this.getField("Subtotal");
var b = this.getField("ComboBox2");

if (b = "QC" ) event.value = Math.round (a.value * 15) / 100;
if (b = "ON" ) event.value = Math.round (a.value * 8) / 100;
if (b = "AB" ) event.value = Math.round (a.value * 5) / 100;

Any suggestions?

EDIT: Using Acrobat 8 Pro, not Standard as indicated below.

My Product Information:
Acrobat Standard 8.0, Macintosh
try67
Expert
Registered: Oct 30 2008
Posts: 2399
You're not using the correct operator. "=" is the assignment operator. You need to use "==" for comparisons. Also, you're not looking at the value property. Change your code like so:

if (b.value == "QC" ) event.value = Math.round (a.value * 15) / 100;
if (b.value == "ON" ) event.value = Math.round (a.value * 8) / 100;
if (b.value == "AB" ) event.value = Math.round (a.value * 5) / 100;

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

AndresMtl
Registered: Apr 15 2010
Posts: 3
Thanks a bunch, that seems to have done it.