How to control objects presence through a drop down list selection?

Avatar

Avatar
Validate 1
Level 1
charlierobledo
Level 1

Likes

0 likes

Total Posts

5 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 1
charlierobledo
Level 1

Likes

0 likes

Total Posts

5 posts

Correct reply

0 solutions
Top badges earned
Validate 1
View profile
charlierobledo
Level 1

28-09-2018

Hi,

I have a drop-down list that has about 30 items. I know you can create an action to show an object when certain text in the drop down is selected. However, the object does not go back to "hidden" when other text is selected in the drop-down list. How can I make it so the object appears only when certain items are selected and the rest make it go back to hidden? Is there an easy script for this?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Validate 1
Level 4
mouslander
Level 4

Likes

23 likes

Total Posts

298 posts

Correct reply

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

Avatar
Validate 1
Level 4
mouslander
Level 4

Likes

23 likes

Total Posts

298 posts

Correct reply

27 solutions
Top badges earned
Validate 1
Boost 5
Boost 3
Boost 10
Boost 1
View profile
mouslander
Level 4

10-10-2018

you would need to have a second action. For example if you have Apple, Banana, Orange and the user selects Banana and a field is displayed (visible) but when the select Orange the field that displayed for Banana is now hidden.

You would need something like"

if(this.rawValue == "Banana"){

field1.presence = "visible"

}

else{

field1.presence = "hidden"

}

This could be a mess if you have 30 fields in the drop down and each would have its own hidden field. Another way to do this is to use one field and dynamically change the field value for example:

if(this.rawValue == "Banana"){

field1.presence = "visible"

field1.rawValue = "I love Banana"

}

else

if(this.rawValue == "Orange"){

field1.presence = "visible"

field1.rawValue = "Oranges are good for you"

}

An even cleaner way to do this is with a case statement.

Answers (1)

Answers (1)

Avatar

Avatar
Establish
MVP
_Bruce_Robertson
MVP

Likes

271 likes

Total Posts

1,782 posts

Correct reply

372 solutions
Top badges earned
Establish
Give Back 25
Give Back 10
Give Back 5
Give Back 3
View profile

Avatar
Establish
MVP
_Bruce_Robertson
MVP

Likes

271 likes

Total Posts

1,782 posts

Correct reply

372 solutions
Top badges earned
Establish
Give Back 25
Give Back 10
Give Back 5
Give Back 3
View profile
_Bruce_Robertson
MVP

28-09-2018

Hi

I don't think you can do this with the action builder, you will have to manually write the script, something like this JavaScript in the change event of the drop down.

if ($.boundItem(xfa.event.newText) == "?????") {

  this.resolveNode("TextField1").presence = "visible";

} else {

  this.resolveNode("TextField1").presence = "hidden";

}


You will need to change the "?????" bit to the display value in your dropdown and the this.resolveNode("TextField1") bit to reference whatever field you are trying to make hidden