Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Populating dropdown list from textfields

Avatar

Former Community Member

Greetings:

I cannot get this to work.

I am trying to populate a dropdown list with responses contained in several textfields.

I have tried

".addItem(textfield1)

.addItem(textfield2)"

That returns "empty" and repeats the  textfields' values.

Help is appreicated. Thank you.

Steven

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

The syntax for JavaScript in the preOpen event of the dropdown would be:

this.addItem(textfield1.rawValue);

But you would also want to include script to clear the items first, otherwise the items on the dropdown would multiply everytime it is opened:

this.rawValue = null;

this.clearItems();

this.addItem(textfield1.rawValue);

this.addItem(textfield2.rawValue);

You can see this type of script in action here: http://assure.ly/jcTahK and here: http://assure.ly/gcXx03.

Hope that helps,

Niall

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

Hi,

The syntax for JavaScript in the preOpen event of the dropdown would be:

this.addItem(textfield1.rawValue);

But you would also want to include script to clear the items first, otherwise the items on the dropdown would multiply everytime it is opened:

this.rawValue = null;

this.clearItems();

this.addItem(textfield1.rawValue);

this.addItem(textfield2.rawValue);

You can see this type of script in action here: http://assure.ly/jcTahK and here: http://assure.ly/gcXx03.

Hope that helps,

Niall