Acrobat User Community Forums

You are not logged in.     Log in to your AUC account.     Don't have an account? Sign up today

#1 2007-04-09 14:40:48

djfixxx
Member

Registered: 2007-04-30
Posts: 0

Field Calculation

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.


My Product Information:
Acrobat Pro 8 / Windows

Offline

 

#2 2007-04-09 16:15:43

thomp
Member

Registered: 2007-04-23
Posts: 853

Re: Field Calculation

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

Code:

// The first Radio Button is M
// and the second Radio Button is A
if(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.

Offline

 

#3 2007-04-09 16:35:00

djfixxx
Member

Registered: 2007-04-30
Posts: 0

Re: Field Calculation

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?

Offline

 

#4 2007-04-09 16:36:39

djfixxx
Member

Registered: 2007-04-30
Posts: 0

Re: Field Calculation

Oops sorry I meant Text Fields not Test Fields

Offline

 

#5 2007-04-09 16:36:39

djfixxx
Member

Registered: 2007-04-30
Posts: 0

Re: Field Calculation

Oops sorry I meant Text Fields not Test Fields

Offline

 

#6 2007-04-10 10:37:48

djfixxx
Member

Registered: 2007-04-30
Posts: 0

Re: Field Calculation

How can I do this in Acrobat 8 Pro?

Offline

 

#7 2007-04-10 11:23:47

thomp
Member

Registered: 2007-04-23
Posts: 853

Re: Field Calculation

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)

Code:

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;

Offline

 

#8 2007-04-10 12:26:59

djfixxx
Member

Registered: 2007-04-30
Posts: 0

Re: Field Calculation

If I could kiss you I would :)

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

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson

AcrobatUsers.com  >>  User Groups • News • Events • Articles • Blogs • How To • Resources • Member Log in