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;
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!
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!
I found a youtube video that shows you how to populate the dropdown menu from a list. You have to fill the dropdown menu options, then you can select from the dropdown.
Here is the table I took the author from:
var author=getColumn(“Best Selling Books”, “Author”);
The dropdown box is authorDropDown. The authors get displayed in displayAuthors.
//THE 2 ONEVENTS BELOW FILL THE DROPDOWN BOX FROM A LIST
onEvent(“authorDropDown”, “click”, function( ) {
authorChoice=getText(“authorDropDown”);
filterAuthor();
});
//THIS FUNCTION FILTERS THE DATA BY AUTHOR
function filterAuthor(){
filteredAuthor=;
filteredBookList=;
for (var i = 0; i < author.length-1; i++) {
if (author[i]==authorChoice){
appendItem(filteredAuthor, author[i]);
appendItem(filteredBookList, bookList[i]);
}
}
}
Here is what I gave my students who wanted to populate the options on a dropdown box from a list. It works.
FILLING THE DROPDOWN MENU FROM A LIST
This is how to upload a dropdown box from a list. I want to upload the Author column from the Table: Best Selling Books. I am calling the list for the dropdown menu author. The dropdown menu is call “authorDropDown”.
var authorList=getColumn(“Best Selling Books by Author”, “author”);
//THIS ONEVENT AND FUNCTION WILL FILL THE DROPDOWN BOX FROM A LIST