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

Computing field value based on If statements

goslinc
Registered: Sep 25 2007
Posts: 114

I have no idea if or how to do this. I have a form created in live cycle designer and based on a yes or no being answered in a field called Qstn1, and amount in field AmtOfIssue, I need a figure to be calculated in another field on the form called FEE.

So, if Qstn1 = yes, then IF AmtOfIssue *0.0002>1000 FEE=1000
IF AmtOfIssue *0.0002<100 FEE=100
ELSE FEE = AmtOfIssue*0.0002

Can I do this (with your help of course)?

My Product Information:
LiveCycle Designer, Windows
Dimitri
Expert
Registered: Nov 1 2005
Posts: 1389
Hi goslinc,

Sure, you can write complex conditional statements like that for your form. Here's a tutorial that should be helpful-
http://www.acrobatusers.com/tutorials/conditional-execution

Hope this helps,

Dimitri
WindJack Solutions
www.pdfscripting.com
www.windjack.com
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
You could simplify your calculation by computing the fee before any value testing, and then use the computed value to test for maximum and minimum fees.

var fee = this.getField('FEE'); // get the fee field objectfee.value = 0; // clear the fee field value// if question 1 is yes then compute feeif (this.getField('Qstn1').value == yes) {fee.value = this.getField('AmtOfIssue).value * 0.0002; // test fee value// test for over maximum feeif (fee.value > 1000) fee.value = 1000; // maximum value// test for below minimum feeif (fee.value < 100) fee.value= 100; // minimum value} // end if Qstn1

George Kaiser

goslinc
Registered: Sep 25 2007
Posts: 114
Where would this code get placed, on what field after what type of event?
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
Are you creating your form in LiveCycle Designer or are you using Acrobat using the form tool?

George Kaiser

goslinc
Registered: Sep 25 2007
Posts: 114
The form is created in LiveCycle Designer.
gkaiseril
Online
Expert
Registered: Feb 23 2006
Posts: 4308
Then you need to be using FromCalc or LiveCycle Designer JavaScirpt for the calcultion script. But the script I posted was for an Acrobat form.
var fee = 0 // clear the fee value// if question 1 is yes then compute feeif (Qstn1 == 1) thenfee = AmtOfIssue.rawValue * 0.0002  // test fee value// test for over maximum feeif (fee > 1000) thenfee = 1000 // maximum valueendif // maximum value// test for below minimum feeif (fee.< 100)  thenfee = 100  // minimum valueendif // minimum valueendif // Qstn1$.rawValue = fee //set the field value

George Kaiser

goslinc
Registered: Sep 25 2007
Posts: 114
But does this go on the calculate event for the Fee field? It would have to go elsewhere wouldn't it ?