Implementazione form aggiunta

This commit is contained in:
2025-11-13 09:10:46 +01:00
parent a28fdb198b
commit f38f06bef6
3 changed files with 33 additions and 3 deletions

View File

@@ -84,7 +84,7 @@ function editPizza(id){
}
}
function addPizza(nome, id, prezzo){
function addPizza(id, nome, prezzo){
const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
@@ -105,10 +105,20 @@ function addPizza(nome, id, prezzo){
.then((response) => response.text())
.then((result) => {
alert("Pizza aggiunta con successo!");
listPizze();
window.close();
})
.catch((error) => {
console.error(error)
alert("Errore nell'aggiunta, controllare la console per dettagli sull'errore.");
});
}
function handleAddPizza(event){
event.preventDefault();
const nome = document.getElementById("name").value;
const id = document.getElementById("id").value;
const prezzo = document.getElementById("price").value;
addPizza(id, nome, prezzo);
}