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

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

Explorer ,
Mar 02, 2023 Mar 02, 2023

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
2.0K
Translate
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
1 ACCEPTED SOLUTION
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.

View solution in original post

Translate
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

Try changing field calculation order. 

Translate
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

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;
}
Translate
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

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.

Translate
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
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!

Translate
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