I want to add two select boxes to a panel. When I select from the the first select box, a second select box to be shown. The problem is that when I select from the first box second box loads again and again. Here is my script link


enter image description here

1 Answer 1


Your province dropdown is created inside the country_selected() function, which runs every time a country is picked from the country dropdown. Move the province dropdown creation outside of this function instead.

If you need it to show up only once a country has been picked, then create it but hidden (style: {shown: false}) and make country_selected() show it using province_select.style().set('shown',true).

The country_selected() function could also populate it with the right province list for that country at that point (the link in the question adds the same province list for either country).

Also remove the Map.clear() and Map.add(mainPanel) inside country_selected() to avoid the flicker.

Fixed version: https://code.earthengine.google.com/0b1fa05ed9de11974dd272e30ed88c4e


Not the answer you're looking for? Browse other questions tagged or ask your own question.