Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
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