I am creating a app on app lab (code.org) and I want to display a list of items from my records to a dropdown. This dropdown will be used for options.

readRecords("data",{},function(record) {
  for(var i = 0 ; i < record.length ; i++) {
    setProperty("list","options",[getProperty("list","options"),record[i].items]);
  }
});

When I was writing this code, I imagined that it would display each item individually inside the dropdown. However, this did not occur; instead, it display every item inside one option in the dropdown except for the last, which was actually placed at the last index of the dropdown. It looked like this:

option1option2option3

option4

I do not have any idea of how to fix this. Please help!

1

There are 1 best solutions below

0
On

Your on the right track, but you have the parameters of your setProperty() slighly off. The third parameter can be the list, code.org then will take that list and make all items in that list into options in your drop down.

readRecords("data",{},function(record) {
  setProperty("list","options",record);
});

You can tell what they pick by using

onEvent("dropdown1", "change", function( ) {
    var x = getProperty("dropdown1","text")
    console.log(x);
});