This repository has been archived on 2024-04-05. You can view files and clone it, but cannot push or open issues or pull requests.
score-tracker/public/scripts/submit.js
2021-11-21 15:40:48 -07:00

33 lines
No EOL
815 B
JavaScript

import * as Data from "./data.js";
const sportDropdown = document.getElementById('sport-dropdown');
const seasonDropdown = document.getElementById('year-dropdown');
async function listSports() {
const sportsList = await Data.getSports();
sportsList.forEach(sport => {
const option = document.createElement('option');
option.text = sport.name;
option.value = sport.id;
sportDropdown.appendChild(option);
});
}
listSports();
async function listSeasons() {
const seasonsList = await Data.getSeasons();
seasonsList.forEach(season => {
const option = document.createElement('option');
option.text = season.year - 1 + "-" + season.year;
option.value = season.id;
seasonDropdown.appendChild(option);
});
}
listSeasons();