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

Field Calculation

djfixxx
Registered: Mar 22 2007
Posts: 111

I need to have a text field that if a user enters A the outcome will equal 0.485 and if they enter M it will equal 0.305.
 
So 3 Fields all together.
Field1 A=Auto or M=Motorcycle.
Field2 = Mileage
Field3 = Mileage dollar amount.
 
So something like Field1 = A,
Field2 = 12, Field3 = $5.82
field3 based on A=0.485 x 12
or if they enter M, M=0.305 x 12.
Export Value Will Not Work
I have 16 of the same fields.

It professional, networking, technical, graphical, imaging, froms.

My Product Information:
Acrobat Pro 8, Windows
thomp
Expert
Registered: Feb 15 2006
Posts: 4411
I'm assuming your using a LiveCycle form. If not then the technical details are different.

First, your better off using radio buttons to make the selection. Use JavaScript in the calculation script. So, for a radio button group named "RateSelect" the calculation code could look like this

// The first Radio Button is M// and the second Radio Button is Aif(RateSelect.rawValue == 1)this.rawValue = Milage.rawValue * 0.305;else if(RateSelect.rawValue == 2)this.rawValue = Milage.rawValue * 0.485;
the export value of the radio buttons can be set in the Binding tab to anything, text or number. If you don't set them then a value of "0" means that none are selected, a value of "1" means that the first radio button is selected, a value of "2" means that the second radio button is selected, etc.

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

djfixxx
Registered: Mar 22 2007
Posts: 111
I am using Acrobat 8 Pro, I've tried radio buttons but getting errors when I reset the form.
So If I can I want to use Test Fields for A and M.
Will this script work in 8 Pro?

It professional, networking, technical, graphical, imaging, froms.

djfixxx
Registered: Mar 22 2007
Posts: 111
Oops sorry I meant Text Fields not Test Fields

It professional, networking, technical, graphical, imaging, froms.

djfixxx
Registered: Mar 22 2007
Posts: 111
Oops sorry I meant Text Fields not Test Fields

It professional, networking, technical, graphical, imaging, froms.

djfixxx
Registered: Mar 22 2007
Posts: 111
How can I do this in Acrobat 8 Pro?

It professional, networking, technical, graphical, imaging, froms.

thomp
Expert
Registered: Feb 15 2006
Posts: 4411
The technique is the same no matter what forms technology or input field your using.

1. Acquire the value from the input field
2. Use it so select between two calculation options.

It seems you are getting hung up in the details. Here's a example using a text field for input on an AcroForm (Acrobat Form)

var cSelect = this.getField("InputField").value;var nMilageVal = this.getField("Milage").value; if(cSelect == "M")event.value = nMilageVal * 0.305;else if(cSelect == "A"))event.value = nMilageVal * 0.485;

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

djfixxx
Registered: Mar 22 2007
Posts: 111
If I could kiss you I would :)

But we'll just keep this on the Down Low, you are a HUGE help.

It professional, networking, technical, graphical, imaging, froms.