Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

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

Avatar

Level 1

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

1 Accepted Solution

Avatar

Correct answer by
Level 7

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.

View solution in original post

2 Replies

Avatar

Level 10

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

Avatar

Correct answer by
Level 7

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.