Skip to main content
Participant
December 30, 2020
Answered

Field visibility seems inverted

  • December 30, 2020
  • 2 replies
  • 651 views

im trying to hide one field when a dropdown list has a particular value.

I have an on validate script as follows

var fdtime = this.getField("FDTime1");
var fdelement = this.getField("FDElement1");
if (fdtime && fdelement)
{
    if (fdelement.value == "CStSq")
    {
     fdtime.display = display.hidden;
    }
    else
    {
     fdtime.display = display.visible;
    }
}

This works, but when the dropdown list has my comparison value "CStSq" the time field is visible and when It doesn't have the value the time field is visible.  The exact opposite of what I expect this code to be doing. 

This topic has been closed for replies.
Correct answer try67

Also, you should use event.value to access the new value. When you use getField().value it returns the field's current value (ie. the one before the new value has been applied, since it is still being validated at that point)...

2 replies

try67
Community Expert
Community Expert
December 30, 2020

Make sure to set the option to commit the selected value of the drop-down field immediately (under Properties - Options).

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
December 30, 2020

Also, you should use event.value to access the new value. When you use getField().value it returns the field's current value (ie. the one before the new value has been applied, since it is still being validated at that point)...

Haley5F9BAuthor
Participant
January 5, 2021

Thanks for the prompt response. 

This works fine for my acrobat reader on PC.

However for Acrobat reader on my Android phone the field simply always stays invisible.

I am waiting for a friend to try on his MAC book / iphone to see how they behave.

 

The behaviour seems inconsistent across platforms.

Haley5F9BAuthor
Participant
December 30, 2020

Sorry that should have said.

This works, but when the dropdown list has my comparison value "CStSq" the time field is visible and when It doesn't have the value "CStSq" the time field is hidden.  The exact opposite of what I expect this code to be doing.