Coding list in dropdown menu

Is it possible to populate the dropdown choices from a list? Here is what I have tried:

What happens is that the dropdown is added but everything is on one line rather than each line being a separate choice. My search algorithm is still sketchy, but its just the formatting the dropdown I can’t figure out, thanks!

var Platform = getColumn(“Best Selling Video Games”, “Platforms”);
var Publisher = getColumn(“Best Selling Video Games”, “Publisher”);
var UniquePlat = ;
UniquePlat[0] = Platform[0];
var UniquePub = ;
UniquePub[0] = Publisher[0];
var temp;

console.log("Platform = " + Platform[0]);
console.log("UniquePlat = " + UniquePlat[0]);

for (var i = 0; i < 50; i++) {
for (var j = 0; j < UniquePlat.length; i++) {
if (Platform[i] != UniquePlat[j]){
temp = Platform[i];
j = UniquePlat.length;
}
}
appendItem(UniquePlat, temp);
}

for (i = 0; i < 50; i++) {
for (j = 0; j < UniquePub.length; i++) {
if (Publisher[i] != UniquePub[j]){
temp = Publisher[i];
j = UniquePub.length;
}
}
appendItem(UniquePub, temp);
}

console.log(UniquePub.length);
for (i = 0; i < UniquePub.length; i++) {
console.log(UniquePub[i]);
}

setProperty(“PlatformDropdown”, “options”, [UniquePlat]);
setProperty(“PublisherDropdown”, “options”, [UniquePub]);

Hello,

Generally your theory works, except instead of [UniquePlat] being your input, you need to actually input the index: UniquePlat[0]. You can add more parameters, but you’d need to know the length of the list which makes this tricky because it may vary depending on the input.

I can think of a few ways to do it, but none particularly easy and none that I would fee comfortable teaching a student at this level. I’ll keep thinking!

1 Like

Did anyone figure out how to do this? My students need to do this (use a list created in the code as the options for a dropdown list on a secondary screen) for the Hackathon project. Thanks!