Skip navigation
NWTGrain
Currently Being Moderated

Formulas for If Statement and Subtraction

Jun 5, 2009 4:20 PM

I am building a pdf form with Adobe and need help with using the custom calculation feature of the form builder.  I have never programmed in Java before so if someone can help with converting these formulas to Java Script that would be great.

 

The first formula that I need help with is

 

Text Box D = Text Box A- Text Box B -Text Box C

 

The second formula is

 

Text Box F =If (Text Box E >0, Text Box E, Blank)

Text Box G = If ("Text Box E<0, Absolute Value of Text Box E, Blank)

 

Also - I am having trouble with sequencing the text fields.  I like scrolling through the form fields using the tab key. Is there any way of changing the sequence of the fields so that you can choose which field comes up next after hitting tab?

 

Thanks in Advance

 

Dan

 
Replies
  • Currently Being Moderated
    Jun 6, 2009 10:24 AM   in reply to NWTGrain

    Acrobat forms use JavaScript not the Java language, and Acrobat has some special objects, properties, and methods that are unique to Acrobat. If you use LiveCycle Designer, that programs JavaScript has differences from Acrobat's JavaScript, but it can use most of Acrobat's JavaScript but with modification.

     

    For form field 'D' you can use the following 'Custom calculation script':

     

    // get the numeric value of the following fields

    var A = Number(this.getField('A').value);

    var B = Number(this.getField(B').value);

    var C = Number(this.getField('C').value);

    // set the value of F

    event.value = A - B - C;

     

    For form field 'F' you can use the following 'Custom calculation script':

     

    // get the numeric value of the field 'E'

    var E = Number(this.getField('E').value);

    // set the value of field F based on E's value

    if(E > 0) {

    event.value =  E; // the value of E

    } else {

    event.value = ''; // blank F

    }

     

    For form field 'G' you can use the following 'Custom calculation script':

     

    // get the numeric value of the field 'E'

    var E = Number(this.getField('E').value);

    // set the value of field F based on E's value

    if(E < 0) {

    event.value =  Math.abs(E); // the absolute value of E

    } else {

    event.value = ''; // blank G

    }

     

     

    To modify the tab order of fields, you need to select "Forms => Edit form in Acrobat" and then select "Forms =>   Edit Fields => Set Tab Order" and answer "No" to the auto tab order question. You will then be able to select the field you want to change the tab ordering for and left mouse click to change the tab #.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points