54 lines
1.7 KiB
JavaScript
Raw Normal View History

2024-04-17 10:06:18 +02:00
const swiper = new Swiper('.swiper', {
direction: 'vertical',
loop: true,
pagination: {
el: '.swiper-pagination',
},
});
2024-04-17 23:14:22 +02:00
// Für die Links in der Navbar, dass die Striche beim aktuell geklickten bleiben
document.addEventListener("DOMContentLoaded", function() {
var navLinks = document.querySelectorAll('.navbar .nav-link');
var initialSelected = document.querySelector('.navbar .nav-link[aria-current="page"]');
if (initialSelected) {
initialSelected.classList.add('selected');
}
navLinks.forEach(function(link) {
link.addEventListener('click', function() {
// Alle anderen Links zurücksetzen
navLinks.forEach(l => l.classList.remove('selected'));
// Die 'selected' Klasse zum angeklickten Link hinzufügen
link.classList.add('selected');
});
});
});
2024-04-18 15:51:37 +02:00
// Für Patenshop
document.getElementById('donationForm').addEventListener('submit', function(event) {
2024-04-18 16:47:42 +02:00
event.preventDefault();
2024-04-18 15:51:37 +02:00
alert('Alles in Ordnung. Vielen Dank für Ihre Spende!');
2024-04-18 16:47:42 +02:00
this.reset();
2024-04-18 15:51:37 +02:00
});
2024-04-18 16:47:42 +02:00
2024-04-18 16:36:22 +02:00
// Für Preis
document.addEventListener('DOMContentLoaded', function() {
2024-04-18 16:47:42 +02:00
updatePrice();
2024-04-18 16:36:22 +02:00
});
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;
2024-04-18 16:47:42 +02:00
priceInput.value = total.toFixed(2);
2024-04-18 16:36:22 +02:00
}
function showDonationAmount() {
const priceInput = document.getElementById('Preis').value;
alert('Danke für deine Spende von €' + priceInput + '!');
}