U3 Lesson 8 dropdown boxes help!

My students have designed their apps using dropdown boxes, but when we try to code the dropdown boxes, there is no block for them.
Does anyone know how to do that?
Thanks!

Usually for a dropdown you have an onEvent that triggers on “change” and you get the text from the dropdown and do something with it. Here’s a simple example

Dropdown boxes work almost the same as any other widget. You create an onEvent for it. In the case of dropdowns you will use “change” as your event type.

In the above code we see an example of using an onEvent. We also have a setProperty block to change the list of potential values in the dropdown.

One thing you can run into with a dropdown is the onEvent isn’t triggered unless the value chosen is changed. So it is useful to put a dummy value into the box so that it must be changed.

In the above app we have made “Choose one…” our default value. We can use an if to ignore it in the onEvent.

Thank you! That’s a great start. I’ll give it a shot. :slight_smile:

thank you! that’s very helpful! :slightly_smiling_face: