Dropdown Menu - Adding an extra space in options
22:34 11 Nov 2025

I'm currently in a Coding class and I'm making an app for a project. We have to insert Datasets into our app. The problem I am having is when I use my dropdown menu for my options in my data set, after the first time the code is run, code.org is adding and enter space in the design tab after my options which makes it not work anymore. AKA: The little white space after all the options.

This is the code I have right now.

onEvent("searchMajorsButton", "click", function( ) {
setScreen("searchScreen");
});

onEvent("searchMajorButton", "click", function() {
  var salaryWanted = getText("salaryInput");
  var categoryChosen = getText("majorCategoryDropdown");
  if (salaryWanted != "Any") {
    salaryWanted = Number(salaryWanted);
  }
  readRecords("College Majors & Incomes", {}, function(records) {
    var filtered = records.filter(function(item) {
      var matchesSalary = true;
      var matchesCategory = true;
      if (salaryWanted != "Any") {
        matchesSalary = (item.Median >= salaryWanted);
      }
      if (categoryChosen != "Any") {
        matchesCategory = (item.Major_category == categoryChosen);
      }
      return matchesSalary && matchesCategory;
    });
    if (filtered.length > 0) {
      var major = filtered[0];
      var employmentRate = Math.round((major.Employed / major.Total) * 100);
      setText("resultMajorName", major.Major);
      setText("resultMajorCategory", major.Major_category);
      setText("resultMedianSalary", "$" + major.Median);
      setText("resultEmploymentRate", employmentRate + "%");
    } else {
      setText("resultMajorName", "No matching majors found");
      setText("resultMajorCategory", "-");
      setText("resultMedianSalary", "-");
      setText("resultEmploymentRate", "-");
    }
    setScreen("resultsScreen");
  });
});
onEvent("backButton1", "click", function( ) {
  setScreen("homeScreen");
});
onEvent("backButton3", "click", function( ) {
  setScreen("homeScreen");
});
onEvent("backButton2", "click", function() {
  setScreen("searchScreen");
  setProperty("salaryInput", "text", "Any");
  setProperty("majorCategoryDropdown", "text", "Any");
});
onEvent("homeButton", "click", function( ) {
  setScreen("homeScreen");
});
onEvent("viewMajorsButton", "click", function( ) {
  setScreen("allMajorsScreen");
    setText("allMajorsTextArea", "Loading majors...");
  readRecords("College Majors & Incomes", {}, function(records) {
    var majorsText = "";
    for (var i = 0; i < records.length; i++) {
      majorsText += (i + 1) + ". " + records[i].Major + " (" + records[i].Major_category + ")\n";
    }
    setText("allMajorsTextArea", majorsText);
  });
});
onEvent("filterByCategoryButton", "click", function( ) {
  setScreen("searchScreen");
});
onEvent("salaryInput", "change", function( ) {
    console.log("Selected option: " + getText("salaryInput"));
});
javascript drop-down-menu dataset dropdown