Skip to main content
July 10, 2019
Answered

how to add javascript to show/hide field

  • July 10, 2019
  • 1 reply
  • 956 views

i have tried 2 methods to add a way to show/hide a label from a dropdown event.
method 1 - add to the dropdown > format > custom keystroke script

var lblServiceUnit = this.getField("lblServiceUnit");

var FacilityType = this.getField("Facility Type");  

console.println(FacilityType.value);

if (FacilityType.value=="Federal") {  

    lblServiceUnit.display = display.visible;    

} else {  

    lblServiceUnit.display = display.hidden;    

}

when i change the drop down it always seems to printout the last value and not the current value. i am changing the dropdown via mouse.

method 2 -
dropdown > actions > select trigger > ? mouse up or onblur or mouse exit
the javascript added here is the same as above but it does not seem to fire at the right time. i have to click out and sometimes click back into the dropdown to see it fire.

This topic has been closed for replies.
Correct answer try67

Go to the properties of the drop-down and under the Options tab tick the "Commit selected value immediately".

1 reply

try67
Community Expert
Community Expert
July 10, 2019

Move the code to the validation event and use event.value instead of FacilityType.value .

July 10, 2019

this event.value at this point in validation event works but ONLY when you focus off the drop down.
same thing for the events in the ACTION tab (on blur, on mouse down enter exit)
for the ACTION (on mouse down enter exit) the event is blank and the direct value is unchanged UNTIL i defocus off the dropdown.
for the ACTION (onblur) it correctly works as validation event works but ONLY when you focus off the drop down.

is there no way to this to fire when the drop down changes but does not lose focus?
i am having 3 different options show up after selecting a choice from the dropdown. it seems confusing that the end user won't see those options UNTIL he defocuses off the dropdown.

so i can get this working but seems unfriendly to the end user.

try67
Community Expert
try67Community ExpertCorrect answer
Community Expert
July 10, 2019

Go to the properties of the drop-down and under the Options tab tick the "Commit selected value immediately".