dwm-app/static/js/updateMonsterFamily.js

22 lines
892 B
JavaScript
Raw Permalink Normal View History

2024-02-21 14:58:42 +00:00
function updateMonsterFamily() {
// Get the selected monster from the dropdown
var selectedMonster = document.getElementById("monsterDropdown").value;
2024-02-21 17:38:00 +00:00
2024-02-21 14:58:42 +00:00
// Make an API request to get the stats for the selected monster
fetch(`/api/monster/stats?monster=${selectedMonster}`)
.then(response => response.json())
.then(data => {
2024-02-21 17:38:00 +00:00
// Function to capitalize the first letter
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
// Update the HTML content with the capitalized monster family
2024-02-21 14:58:42 +00:00
var familyContainer = document.getElementById("monsterFamilyContainer");
2024-02-21 17:38:00 +00:00
familyContainer.innerHTML = `<h2>Family: ${capitalizeFirstLetter(data.Family)}</h2>`;
2024-02-21 14:58:42 +00:00
})
.catch(error => {
console.error("Error fetching monster family:", error);
});
2024-02-21 17:38:00 +00:00
}