53 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			53 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| const swiper = new Swiper('.swiper', {
 | |
|     direction: 'vertical',
 | |
|     loop: true,
 | |
| 
 | |
|     pagination: {
 | |
|       el: '.swiper-pagination',
 | |
|     },
 | |
| });
 | |
| 
 | |
| // 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');
 | |
|       });
 | |
|   });
 | |
| });
 | |
| // Für Patenshop
 | |
| document.getElementById('donationForm').addEventListener('submit', function(event) {
 | |
|   event.preventDefault(); // Verhindert die tatsächliche Formularübermittlung
 | |
|   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 + '!');
 | |
| }
 |