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

Acrobat fields acting slow on updating on input

Community Beginner ,
Mar 15, 2021 Mar 15, 2021

Copy link to clipboard

Copied

Hi All

 

Basically, I've created a dynamic fields PDF which include some javascript boxes calculating multiple fields across 3 lines. When the fields have numbers entered, the first two rows seem fine but then the third row seems out of sync (ie: when number is inputted into field box, the sums do not update instantly until I move to another field and alter the number - then all it does is continue to be one step behind on adding all of the relevant field boxes up. 

 

I've attached a couple of screenshotsScreenshot 2021-03-15 at 16.09.49.pngScreenshot 2021-03-15 at 16.09.03.png to see if anyone can tell me where I'm going wrong? The issue I'm having is the 3rd row which when I input a quantity in QTY box, it's not updating costs in the far right box.

 

Many thanks for anyone who can solve this issue!! 🙂

TOPICS
How to , JavaScript , PDF forms

Views

977

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

Community Expert , Mar 15, 2021 Mar 15, 2021

Change the field calculation order.

Votes

Translate

Translate
Community Expert ,
Mar 15, 2021 Mar 15, 2021

Copy link to clipboard

Copied

Hi,

 

Are you using the "calculate" event, if so this recalculates all fields whenever any field is changed, might be better to move to the validate event as it is only called when the actual fields itself are changed, although this can require some additional coding.

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 Beginner ,
Mar 15, 2021 Mar 15, 2021

Copy link to clipboard

Copied

I have to admit, I'm just beginning to get used to creating dynamic forms in Acrobat and I have no idea how to do that? So sorry, it' my first time doing a document like this in Acrobat!

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 Beginner ,
Mar 15, 2021 Mar 15, 2021

Copy link to clipboard

Copied

Here is a link to the test document: https://documentcloud.adobe.com/link/review?uri=urn:aaid:scds:US:2c6b6f66-05c1-467e-a764-d849be4f1ea...

I've also added it as an attachment as an attachment

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 ,
Mar 15, 2021 Mar 15, 2021

Copy link to clipboard

Copied

Change 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
Community Beginner ,
Mar 15, 2021 Mar 15, 2021

Copy link to clipboard

Copied

Thank you so much Bernd and also thank you BarlaeDC. 

I've now placed all of the boxes in correct order of addition and it works fluently when entering quantity. For some reason instead of using the edit field calculation order, I just moved the order in the fields section which only alters the way I can get the user to tab through the PDF!

 

Ahhh Mondays!!

All sorted and thank you for not making me throw the computer or myself out of the window!! 😉

 

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 ,
Mar 15, 2021 Mar 15, 2021

Copy link to clipboard

Copied

LATEST

Hi,


Just to help anyone that comes along in the future and has a similar issue there are some other pieces in your code that can be improved.


taking this field "Q_Inc_Print_MONO_Row3" as an example ( from the document above), the calculate code is

if(Number(this.getField("Qty_3").value == 0)
 event.value = 0
if(Number(this.getField("Qty_3").value) == 1)
 event.value = 24000
if(Number(this.getField("Qty_3").value) == 2)
 event.value = 21600
if(Number(this.getField("Qty_3").value) == 3)
 event.value = 19200
if(Number(this.getField("Qty_3").value) == 4)
 event.value = 16800
if(Number(this.getField("Qty_3").value) >= 5)
 event.value = 14400


The problem with this code is that you are requesting the value from the "this.getField('Qty_3').value", multiple times even though it would not change, so you could alter your code to only call it once and then we could make use of a switch statement to simplify the code to something like :

var qrt3Value = Number(this.getField("Qty_3").value);
switch ( qrt3Value){
 case 0:
  retValue = 0;
  break;
 case 1:
  retValue = 24000;
  break;
 case 2:
  retValue = 21600;
  break;
 case 3:
  retValue = 19200;
  break;
 case 4:
  retValue = 16800;
  break;
 default:
  retValue = 14400;
  break;
}
event.value = retValue;


event.value = retValue;

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