dwm-app/static/js/updateMonsterName.js

16 lines
677 B
JavaScript
Raw Normal View History

2024-02-21 14:00:24 +00:00
function updateMonsterName() {
// Get the selected monster from the dropdown
var selectedMonster = document.getElementById("monsterDropdown").value;
// Make an API request to get the stats for the selected monster
fetch(`/api/monster/stats?monster=${selectedMonster}`)
.then(response => response.json())
.then(data => {
// Update the HTML content with the monster name
var nameContainer = document.getElementById("monsterNameContainer");
2024-02-21 15:31:56 +00:00
nameContainer.innerHTML = `<h2 class="text-3xl font-bold">${data.name}</h2>`;
2024-02-21 14:00:24 +00:00
})
.catch(error => {
console.error("Error fetching monster name:", error);
});
}