Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events
SOLVED

Dynamic Drop Down lists populated with single value as default not showing until down arrow clicked.

Avatar

Level 4

I have over 1600 lines of code to set items to a drop down. In some cases the subsequent drop down only has a single value. I am trying to get the value to show without the user having to click the down arrow. I have tried various events to achieve this. I am using rawValue instead of setItems for those selections which only populate the subsequent drop down with a single option. The client would like the subsequent drop-down to have the singular value show and set the field to readOnly and focus on the third drop down. So far, I have the singular value working but it requires the user to click the down arrow, and, I cannot set the drop-down to readOnly if the field does not show the singular item. So, is there a way to script the down button on a drop-down from another field or the same field?

1 Accepted Solution

Avatar

Correct answer by
Level 10

You can set the selectedIndex property to change the value of a dropdown list. It takes a 0-based integer to select the nth item from the dropdown list.

 

// Select the third item
DropdownList.selectedIndex = 2;

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

You can set the selectedIndex property to change the value of a dropdown list. It takes a 0-based integer to select the nth item from the dropdown list.

 

// Select the third item
DropdownList.selectedIndex = 2;