How to calculate only after field change

New Here ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

I am running Adobe Acrobat Pro DC 2020

I have a form with 5 fields A, B, C, D, E 

I want B to multiply what the user enters by 10 (B*10) in the Simplified field notation

I want E to sum up A,B,C and D (A+B+C+D) in the Simplified field notation

The problem is that B recalculates after each entry into other fields regardless of whether I Tab or Mouse Click.

 

Example: User enters

10 in A field => E = 10

10 in B field which calculates to 100 => E = 110 (so far so good)

10 in C field but now B has recalculated to 1,000 => E = 1,020 (not the desired result)

10 in D field but now B has recalculated again and  = 10,000 => E = 10,030 (not the desired result)

 

I only want B to calculate when I modify that field not when all the other fields are being modified.

How to I fix this?

 

TOPICS
Edit and convert PDFs, JavaScript, PDF forms

Views

95

Likes

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

correct answers 1 Correct Answer

Adobe Community Professional , Feb 04, 2021 Feb 04, 2021
Since a field's calculate event is triggered whenever any field value changes, you should not use it to change the value of field B. Instead, you can use a custom Validate script for field B that's something like: // Custom Validate script for field B if (event.value) event.value = +event.value * 10; What this does is take the value that was entered into field B and multiplies it by ten, if it's not blank. It performs this calculation when the field value is committed, which happens when th...

Likes

Translate

Translate
Adobe Community Professional ,
Feb 04, 2021 Feb 04, 2021

Copy link to clipboard

Copied

Since a field's calculate event is triggered whenever any field value changes, you should not use it to change the value of field B. Instead, you can use a custom Validate script for field B that's something like:

 

// Custom Validate script for field B
if (event.value) event.value = +event.value * 10;

 

What this does is take the value that was entered into field B and multiplies it by ten, if it's not blank. It performs this calculation when the field value is committed, which happens when the user presses Enter, tabs away from the field, or clicks into another field, etc. The field should be set to a numeric format. Be sure to remove the simplified field notation calculation that you set up for field B.

Likes

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 ,
Feb 05, 2021 Feb 05, 2021

Copy link to clipboard

Copied

LATEST

That is exactly what I need. It works perfectly. Thanks 🙂

Likes

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