Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Switch statement default setting

Avatar

Avatar
Validate 10
Level 2
joflo723
Level 2

Likes

4 likes

Total Posts

114 posts

Correct Reply

3 solutions
Top badges earned
Validate 10
Validate 1
Boost 3
Boost 1
Affirm 3
View profile

Avatar
Validate 10
Level 2
joflo723
Level 2

Likes

4 likes

Total Posts

114 posts

Correct Reply

3 solutions
Top badges earned
Validate 10
Validate 1
Boost 3
Boost 1
Affirm 3
View profile
joflo723
Level 2

09-11-2018

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?

Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Coach
MVP
radzmar
MVP

Likes

394 likes

Total Posts

2,682 posts

Correct Reply

489 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile

Avatar
Coach
MVP
radzmar
MVP

Likes

394 likes

Total Posts

2,682 posts

Correct Reply

489 solutions
Top badges earned
Coach
Ignite 3
Ignite 1
Validate 1
Give Back 50
View profile
radzmar
MVP

12-11-2018

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)

Avatar

Avatar
Validate 10
Level 2
joflo723
Level 2

Likes

4 likes

Total Posts

114 posts

Correct Reply

3 solutions
Top badges earned
Validate 10
Validate 1
Boost 3
Boost 1
Affirm 3
View profile

Avatar
Validate 10
Level 2
joflo723
Level 2

Likes

4 likes

Total Posts

114 posts

Correct Reply

3 solutions
Top badges earned
Validate 10
Validate 1
Boost 3
Boost 1
Affirm 3
View profile
joflo723
Level 2

12-11-2018

Thank you Radzmar! That did the trick!

Jo

Avatar

Avatar
Validate 10
Level 2
joflo723
Level 2

Likes

4 likes

Total Posts

114 posts

Correct Reply

3 solutions
Top badges earned
Validate 10
Validate 1
Boost 3
Boost 1
Affirm 3
View profile

Avatar
Validate 10
Level 2
joflo723
Level 2

Likes

4 likes

Total Posts

114 posts

Correct Reply

3 solutions
Top badges earned
Validate 10
Validate 1
Boost 3
Boost 1
Affirm 3
View profile
joflo723
Level 2

12-11-2018

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

My code is:

switch (this.rawValue)

{

//all the cases

default:

    portal.presence = "visible";

    break;

}

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?

Avatar

Avatar
Validate 1
Level 4
MinusZero
Level 4

Likes

30 likes

Total Posts

326 posts

Correct Reply

54 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile

Avatar
Validate 1
Level 4
MinusZero
Level 4

Likes

30 likes

Total Posts

326 posts

Correct Reply

54 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 25
Boost 10
View profile
MinusZero
Level 4

11-11-2018

Hi,

The default case for your switch would be:

default:

//some code for everything else

break;