19 lines
816 B
JavaScript
19 lines
816 B
JavaScript
document.addEventListener("DOMContentLoaded", function () {
|
|
fetch("controladores/obtener-lugares.php")
|
|
.then(response => response.json())
|
|
.then(data => {
|
|
const selectLugar = document.getElementById("lugar");
|
|
data.forEach(lugar => {
|
|
let option = document.createElement("option");
|
|
option.value = lugar.id;
|
|
option.textContent = lugar.nombre;
|
|
option.dataset.capacidad = lugar.capacidad;
|
|
selectLugar.appendChild(option);
|
|
});
|
|
});
|
|
|
|
document.getElementById("lugar").addEventListener("change", function () {
|
|
let capacidad = this.selectedOptions[0].dataset.capacidad || "No seleccionado";
|
|
document.getElementById("capacidad").textContent = capacidad;
|
|
});
|
|
}); |