Keep dropdown placeholder as an option

I have a dropdown with a list of cities from the DB. The placeholder text is “All Cities”.
This is working for the first selection, but then, if the user clicks the dropdown again, he can only select a city, but not to return to “All Cities” mode.
Seems that I need to add a dropdown item with the text “All Cities” to the items array, but I can’t find the syntax.
Does anyone can help?
Thanks:) Dafna

Hey Dafna,

How are you?

You could clear the value from the dropdown, thus restoring the “All” placeholder:

$w('#dropdown1').value = null;

Another option would be to add the “All” option as the first option in the dropdown list:

optionsList.unshift({
    "value": '',
    "label": 'All'
});

I don’t know how you’re building your options list, so this may or may not be applicable to your needs. This is just a simple example of how to add an item to the beginning of a list.

I hope one of these solutions suits your needs.

Yisrael

Thanks Yisrael!!!
The unshift was exactly what I was looking for!!!
The page is not finished yet, but you can see the new line with the placeholder: