4.13 Drop Down Help

csdunit4
applab
lesson13
dropdown

#1

I have a few students who wanted to switch screens using a drop down menu but we have not been able to figure out how to get this to work. Any suggestions would be appreciated.


#2

Dropdowns are bit more complicated than buttons because we need to add a conditional inside the event to check which option was selected. Because this is beyond the scope of programming, students may have to move to the full App Lab to get access to these commands. Assuming a dropdown with id “menu”, your code might look like:

onEvent("menu", "change", function(event) {
  var choice = getProperty("menu", "value");
  if (choice == "Red") {
    setScreen("red");
  } else if (choice == "Green") {
    setScreen("green");
  } else if (choice == "Blue") {
    setScreen("blue");
  }
});

#3

Thanks josh,
I have a student that was playing music from a dropdown list. His code was a bit different but worked in the lab but not on the phone. We will try this.

Norm