Switch statement default setting



I have a dropdown with a switch statement in the exit event with about 80 "cases". There are only 3 of them though that if they are selected, the presence of a text field needs to change to "hidden". Without having to put a "presence" statement on every single case, is there a more efficient way to change the presence of the text field if one of the 3 are selected, and then defaulting back to a "visible" presence if anything else is selected?


Accepted Solutions (1)

Accepted Solutions (1)




You can use a single line of code outside of you switch statement in the dropdown fields change event.

Assuming you want to hide the field when you either select Value12, Value 32 or Value55, the script looks this way:

portal.presence = xfa.event.change.match(/(Value12|Value32|Value55)/gi) ? "hidden" : "visible";

Answers (3)

Answers (3)



I've tried that, but it isn't working.

My code is:

switch (this.rawValue)


//all the cases


    portal.presence = "visible";



The "portal" text field is visible by default, but when you select one of the few options that has it set to hidden, it does disappear, but if you then go back and select any other option that does NOT have its presence specified, it doesn't become visible again. Am I missing anything?