shh
shh

Reputation: 682

Accessing ListBox selected item via UiApp.getActiveApplication().getElementByID()

Currently I am using UiService to create a form and I uses ListBox, from what I understand to pass a value via handler will be something like e.parameter.[Name of ListBox] to access the selected item.

Does anyone know is it possible to use like app.getElementById([Name of ListBox]) to access the selected item. The reason I am using this method is because my list of ListBox-es are dynamic.

Upvotes: 1

Views: 1444

Answers (2)

tadixas
tadixas

Reputation: 36

I spent some time looking for this answer as well, but finally I tried one idea and it worked.

You can use e.parameter as an array so you can these two will give the same:

e.parameter.LIST_BOX_NAME

and

e.parameter['LIST_BOX_NAME']

So in the second sample any dynamic list box ID can be used. I use same handler for all added dropdown list and have this code to check what dropdown was changed and what value it has now:

  if (e.parameter[e.parameter.source] == 'a'){ 

Upvotes: 2

Serge insas
Serge insas

Reputation: 46802

To change the content of the listBox you can use app.getElementById('ID of the listBox'), from there you can clear() and addItems again but you cannot read the listItems. When I need to do this I usually store the list of items somewhere else, in a place that I can read anytime, for example the list of items can be stored as a string in the listBox tag itself so I have all items at hand to repopulate the listBox after I have clear it.

Upvotes: 0

Related Questions