How to display a Dropdown Label. (Solved)

Need help displaying the selected label of the dropdown in a text field for the user (not the value)

Tried using $w(‘#dropdown’).label but it doesn’t exists on Dropdown.

Any ideas of how to do it?

Try:

let dDown = $w(#dropdown");
dDown.onChange((event) => {
    let selectedOption = dDown.options.find(o => o.value === dDown.value);
    let selectedLabel = selectedOption.label;
});
1 Like

Thanks for the reply.
I’ll give it a try and i’ll let you know if this worked.

OK. 2 comments:
I was lazy. You can use the full $w.element if you want.
This method will not work on Internet Explorer

1 Like

Managed to adapt the code to mine.
Thank you, worked flawlessly.

Happy to help :slight_smile:

Would using selectedIndex also work?
label = $w("dropdown).options[$w("dropdown).selectedOption].label?

It should work too.