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

HELP: need auto calculation script for client order form

Registered: Dec 2 2011
Posts: 6

Hey ALL!
I created a basic pdf form -- no frills, just a regular order form that calculate quantity, subtotal and total for a client yesterday. I need to calculate sales tax but only for the home state (client is tracking in vs. out of state sales by vol and Amt). I'm fine here. The client wants a checkbox on the sales tax line, I'm fine there as well.
What I want is to computer and include value for the sales tax amount if the check box is checked, exclude value and return a zero or null value if it isn't checked so the user doesn't have to. The client is in CA so he needs to include sales tax. The sales tax field is already configured to auto-calc the 8.5% rate (0.085).
My problem is the "include/exclude scripts" I've been writing aren't working. I know I'm missing a step, a line or something but I can't figure out what or where. I have the script running in the sales tax (SalesTx) field because that is where the value is calculated or a null value of "zero" is returned, but also other scripts in the checkbox field with a hide/show action control of the SalesTx2/SalesTx fields to display/hide one field with the tax auto-calc'd and the other with a default value of zero (0), and the total field to exclude the SalesTx if hidden.
Nothing is working and I'd appreciate the help. This doesnt need to be complex, i just need the SalesTx field to compute the tax if the checkbox is selcted, return a zero value if the checkbox is not selected.
Here's the setup, followed by the scripts I've written and tested.
Thanks in advance.
Sub Tot: $650.00 | $650.00
CA resident 8.5%[x] 55.25 | [ ] 0.00
S/H: 20.00 | 20.00
TOTAL: $725.25 | $670.00
Here are the Scripts I've Used:
1st one
checkbox.Checked = (valueInSalesTx = Sub*tax); checkbox.NotChecked = (valueInSalesTx = 0); or
2nd one
int valueInSalesTx = 0;
checkbox.Checked = (valueInSalesTx == 0 ? true : false)
3rd try:
var one = this.getField("Checkbox18");
var two = this.getField("Sub");
var three = this.getField("tax");
var four = this.getField("SalesTx");
if (one.value == 'Yes') {
two.valueInSalesTx = 'Sub*tax'
} else if (one.value == 'Off') {
4th try
var one = this.getField("Checkbox18");
var two = this.getField("Sub");
var three = this.getField("tax");
var four = this.getField("SalesTx");
if (one.value == 'Yes') {
four.value == 'Sub*tax'
} else if (one.value == 'Off') {
5th try
var one = this.getField("Checkbox18");
var two = this.getField("SalesTx");
if (one.value == 'Yes') {
two.value == '?'
} else if (one.value == 'Off') {
three.value =='0'
Last one tried earlier today:
var nCheckbox18 = this.getField("Checkbox18");
var nSub = this.getField("sub").value;
if (one.value == 'Yes')
event.value = nSub * 0.085;
event.value = 0;

My Product Information:
Acrobat Pro Extended 9.0, Windows
Registered: Nov 26 2011
Posts: 33
I was able to get this working. I believe it's what you are looking for.
"one" is the name of the checkbox
"TextField1" is the subtotal field
"TextField2" is calculated tax field

if (this.getField("one").value=="Yes")
event.value = this.getField("TextField1").value * 1.085;
this.getField("TextField2").value = .085 * this.getField("TextField1").value;
else event.value = this.getField("TextField1").value;

if (this.getField("one").value=="Off")
this.getField("TextField2").value = "00.00";

console.println("one" + this.getField("one").value);