Patenshop fertig
This commit is contained in:
@@ -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 + '!');
|
||||
}
|
||||
|
Reference in New Issue
Block a user