• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to code the check the value of 2 form fields that must total a specifc number or more

New Here ,
Jan 16, 2020 Jan 16, 2020

Copy link to clipboard

Copied

I have a form here that i'm 98% complete but I just can't figure out one slight detail.

I'm trying to calculate the total of 2 fields to display in a read only field. That part i got worked out half way. It only works to add, if a value that is lesser than the previously entered value, the one field does not redo the math. it simply leaves the original value and stops working. Here is what i need to do.

Form field names:

PWR GVWR
TRL GVWR (this field has to have a value of 10,001 or more, if it does not, must show a flag to the user, that is must be greater than 10,000)

TOTAL GVWR TEXT (Just displays but doesn't print the words TOTAL GVWR. Simple and no need for help on this)

TOTAL GVWR (must have a value of 26001 or more when PWR GVWR and TRL GVWR values are entered. If the total of both do not =26001 or more, then flag the user. this i know how to set the value range which is easy.)

 

I need PWR GVWR + TRL GVWR to add and display those 2 added values into TOTAL GVWR text box. That value needs to be checked to see if it is greater than 26,000. If it is not, it needs throw up a flag to the user and state, that the TOTAL GVWR must be 26,001 or greater. The TRL GVWR field has to have a value of 10,001 or more. If it's not, it throws up a flag to the user to state, the TOTAL GVWR must be greater than 10,000.

 

What i'm having an issue with is 2 sided. First, when i enter 1000 into PWR GVWR and say 29000 into the TRL GVWR the total is added together and displayed in the TOTAL GVWR field. This only works one way. If i reduce the value in the TRL GVWR field, to 27000, the TOTAL GVWR field still shows 30000 and does not do the addition of the 2 fields again. It simply keeps the first entered information in there and stops. Same thing happens if i do the changing in the PWR GVWR field. Does the math once as addition, then stops and if a value is changed it doesn't change the TOTAL GVWR field to display the correct value.

 

Any idea's on how i can get this code to work right?

Here is my code as it sits in each field.

PWR GVWR: Calculate tab, custom script selected.
Code:

var totVal = this.getField("PWR GVWR").value + this.getField("TRL GVWR").value;

if(totVal <26001){
this.getField("Print Button").readonly = true;
}
else
{
this.getField("Print Button").readonly = false;
}

 

TRL GVWR properties: Validate tab, Value is in range from 10001 to 0. Calculate tab:

Code:
var totVal = this.getField("PWR GVWR").value + this.getField("TRL GVWR").value;

if(totVal <26001){
this.getField("Print Button").readonly = true;
}
else
{
this.getField("Print Button").readonly = false;
}

 

TOAL GVWR field properties: Validate tab, value is in range 26001 to 0. Calculate tab, value is the sum+ of the following fields: PWR GVWR, TRL GVWR.

 

In other words what i need this form to do properly is check the math both ways in the PWR GVWR and the TRL GVWR fields to make sure they have a total value of 26,001 or more but the TRL GVWR has to have a value of 10,001 or more no matter what. It does the addition once, then stops. I need it to check the values of both fields no matter what is entered so it can be verified that they both total 26,001 or more. Here are a couple of number examples i use

 

1000 + 25000 = 26000 (flags an error to the user)

1100 + 25000 = 26100 (no flags continue one with your work)

24000 + 10000 = 34000 (flags the error to the user, the TRL GVWR must have a value of 10001 or more. Even though the TOTAL GVWR is greater than 26001, the TRL GVWR field is less than the allowed limit.)

 

 

 

 

TOPICS
Acrobat SDK and JavaScript

Views

418

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 16, 2020 Jan 16, 2020

Copy link to clipboard

Copied

Check the field calculation order.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 16, 2020 Jan 16, 2020

Copy link to clipboard

Copied

I"m not sure what you mean by that. If i change the order i which i select the form fields to calculate it automatically puts them in it's own order by alphabet.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 16, 2020 Jan 16, 2020

Copy link to clipboard

Copied

Under Prepare Form look at "More" on the right side.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 16, 2020 Jan 16, 2020

Copy link to clipboard

Copied

I dont have a prepare form option. i'm using acrobat x standard

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 16, 2020 Jan 16, 2020

Copy link to clipboard

Copied

Sorry, I can't help you with this old version.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 16, 2020 Jan 16, 2020

Copy link to clipboard

Copied

Hi,

 

Follow the guidance in this video:https://m.youtube.com/watch?v=fZdpjmNfY0I 

 

To the right margin of the working space you will see the tags of every field object in your document.

 

On the page that you're working on, identify the fields that have the calculations.

 

 drag and drop the tags above or below other tags to reorder them.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 20, 2020 Jan 20, 2020

Copy link to clipboard

Copied

LATEST

Hi,

 

Just wondering if you were able to identify if your issue had to do with the calculation order in your script or by re-arranging the tags for each calculated field

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines