dwm-app/static/js/indexListener.js
2024-02-23 16:28:37 -05:00

31 lines
1013 B
JavaScript

document.addEventListener("DOMContentLoaded", function () {
const familyDropdown = document.getElementById("familyDropdown");
const monsterDropdown = document.getElementById("monsterDropdown");
// Initialize dropdowns
updateMonsterDropdownByFamily();
// Fetch families data from the server and populate families dropdown
fetch("/api/families")
.then(response => response.json())
.then(data => {
populateDropdown(familyDropdown, data);
})
.catch(error => console.error("Error fetching families:", error));
// Listeners for Dropdown Changes
familyDropdown.addEventListener("change", function () {
updateMonsterDropdownByFamily();
});
monsterDropdown.addEventListener("change", function () {
updateMonsterStats();
updateMonsterName();
updateMonsterFamily();
updateMonsterLocation();
updateMonsterSkills();
updateBreedingPairs();
updateBreedingUsage();
});
});