Patenshop fertig

This commit is contained in:
2024-04-18 16:36:22 +02:00
parent 4dda6c16f0
commit 0fa9a37b3a
2 changed files with 32 additions and 16 deletions

View File

@@ -30,3 +30,23 @@ document.getElementById('donationForm').addEventListener('submit', function(even
alert('Alles in Ordnung. Vielen Dank für Ihre Spende!');
this.reset(); // Setzt das Formular zurück
});
// Für Preis
document.addEventListener('DOMContentLoaded', function() {
updatePrice(); // Initialer Preis wird beim Laden der Seite gesetzt
});
function updatePrice() {
const fresserchenSelect = document.getElementById('Fresserchen');
const mengeSelect = document.getElementById('Menge');
const priceInput = document.getElementById('Preis');
const selectedFood = fresserchenSelect.options[fresserchenSelect.selectedIndex];
const pricePerUnit = selectedFood.getAttribute('data-price');
const quantity = mengeSelect.value;
const total = pricePerUnit * quantity;
priceInput.value = total.toFixed(2); // Preis wird im Preisfeld angezeigt
}
function showDonationAmount() {
const priceInput = document.getElementById('Preis').value;
alert('Danke für deine Spende von €' + priceInput + '!');
}