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

Hidden fields not triggered immediately when another fields calculation value is met

Explorer ,
Mar 02, 2023 Mar 02, 2023

Copy link to clipboard

Copied

I have both a name field and signature field that are to remain hidden until a field called Total has a value of 100 or greater. The Total field is calculating the sum of other fields. The code that I have does not unhide the fields the moment the Total field is 100+, only when another calculation is run thereafter. Also, if the field is unhidden and the value of Total changes to less than 100, then the field does not hide until the next calculation is executed.  What am I missing?

 

var a = this.getField("Total");
var f = event.target;

if (a.value >= 100)  
{
    f.display = display.visible;
}
else if (a.value < 100)
{
    f.display = display.hidden;
}

 

TOPICS
JavaScript , PDF forms

Views

1.0K

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 02, 2023 Mar 02, 2023

To change 'Field calculation order' you need to select 'Prepare form' tool, click on 'More' and select 'Set field calculation order' and make sure fields that should calculate first are on top of the list.

Votes

Translate

Translate
Community Expert ,
Mar 02, 2023 Mar 02, 2023

Copy link to clipboard

Copied

Try changing 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
Explorer ,
Mar 02, 2023 Mar 02, 2023

Copy link to clipboard

Copied

Thank you, Nesa!

I have changed the field calculation order as shown below, but still left with the same problem. If I input 100 into one of the Amount fields and the Total field shows 100, it does not unhide the name and signature fields. It is only when I put a value (even 0) into another Amount field that the name and signature fields appear. It's as if it is a step behind.

var a = this.getField("Total");
var f = event.target;

if (a.value < 100)
{
    f.display = display.hidden;
}

else if (a.value >= 100)  
{
    f.display = display.visible;
}

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 02, 2023 Mar 02, 2023

Copy link to clipboard

Copied

To change 'Field calculation order' you need to select 'Prepare form' tool, click on 'More' and select 'Set field calculation order' and make sure fields that should calculate first are on top of the list.

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
Explorer ,
Mar 03, 2023 Mar 03, 2023

Copy link to clipboard

Copied

LATEST

Thank you, Nesa! I misunderstood. When I looked at the calculation order, the hidden fields were before the Total field. It worked when I reordered 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