fork download
  1.  
  2. // Variables
  3. // Initializing lists
  4. var title = getColumn("Books", "Title");
  5. var author = getColumn("Books", "Author");
  6. var genre = getColumn("Books", "Genre");
  7.  
  8. //Initializing Filtered Lists
  9. var selectedTitle = [];
  10. var selectedAuthor = [];
  11. var genres;
  12.  
  13. //When you click the butttons, the variables change values and take you to the designated screen and shows you a recommended book
  14. onEvent("GenreDD", "change", function( ) {
  15. genres = getText("GenreDD");
  16. });
  17. onEvent("Go", "click", function( ) {
  18. setScreen("bookScreen");
  19. if (genres=="Mystery") {
  20. setText("title2", "Mystery");
  21. } else if ((genres=="Fantasy")) {
  22. setText("title2", "Fantasy");
  23. } else if ((genres=="Horror")) {
  24. setText("title2", "Horror");
  25. }
  26. filter();
  27. });
  28. onEvent("homeButton1", "click", function( ) {
  29. setScreen("titleScreen");
  30. });
  31.  
  32.  
  33. //Filter Function
  34. //If the selected genre matches the genre in the list, append the Titles and Authors to the appropriate list
  35. function filter(input) {
  36. selectedTitle = [];
  37. selectedAuthor = [];
  38. for (var i = 0; i < genre.length; i++) {
  39. if (genre == input) {
  40. appendItem(selectedTitle, title[i]);
  41. appendItem(selectedAuthor, author[i]);
  42. }
  43. }
  44. console.log(selectedTitle);
  45. }
  46. function updateScreen() {
  47. var randomindex = randomNumber(0, 3);
  48. }
  49.  
  50.  
Success #stdin #stdout 0.03s 25360KB
stdin
Standard input is empty
stdout
// Variables
// Initializing lists
var title = getColumn("Books", "Title");
var author = getColumn("Books", "Author");
var genre = getColumn("Books", "Genre");

//Initializing Filtered Lists
var selectedTitle = [];
var selectedAuthor = [];
var genres;

//When you click the butttons, the variables change values and take you to the designated screen and shows you a recommended book
onEvent("GenreDD", "change", function( ) {
  genres = getText("GenreDD");
});
onEvent("Go", "click", function( ) {
  setScreen("bookScreen");
  if (genres=="Mystery") {
    setText("title2", "Mystery");
  } else if ((genres=="Fantasy")) {
    setText("title2", "Fantasy");
  } else if ((genres=="Horror")) {
    setText("title2", "Horror");
  }
  filter();
});
onEvent("homeButton1", "click", function( ) {
  setScreen("titleScreen");
});


//Filter Function
//If the selected genre matches the genre in the list, append the Titles and Authors to the appropriate list 
function filter(input) {
  selectedTitle = [];
  selectedAuthor = [];
  for (var i = 0; i < genre.length; i++) {
    if (genre == input) {
      appendItem(selectedTitle, title[i]);
      appendItem(selectedAuthor, author[i]);
    }
  }
  console.log(selectedTitle);
}
function updateScreen() {
  var randomindex = randomNumber(0, 3);
}