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

clairification re. use of "if" statement using text instead of value

mbush
Registered: Oct 13 2008
Posts: 6

Acrobat 5

Trying to determine the content of a given field (e.g. "state") and depending upon the state, apply a tax to another field ("Total of page 2") and then place the tax amount into a seperate field called "Sales Tax". One version of the code I've tried and does not work is as follows:

var a = this.getField("state");
var b = this.getField("Total of page 2");
var c = 0.07;
var tax = "";
if (a == "Kansas" || a == "KS") {tax = b.value * c};

event.value = tax;

The code to calculate and place the result into a field is not a problem , however, when I try testing content of another field by using an "If" statement and use the above syntax, something is awry.

Thanks in advance for any help!

My Product Information:
Acrobat Standard 5.x or older, Windows
George_Johnson
Expert
Registered: Jul 6 2008
Posts: 1876
You need to look at the "value" property of the state field:

var a = getField("state").value;


George
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Along with George Johnson's suggestion, since you are only using the values of the field objects, set b equal to the value of the state field.

You may also wan to look at using a combo box field for the state selection whch could use the optional value for the selection to set the tax rate. In this manner you do not need to deal with the issues of capitalization of the state text entry.

The script for the sales tax amount could then be:

event.value = this.getField('state').value * this.getField('Total of page 2').value;
if (event.value == 0) event.value = '';

George Kaiser