HTMLify
Education Website (forked) - script.js
Views: 13 | Author: karbonsites
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | document.addEventListener('DOMContentLoaded', () => { // --- Enrollment Form Logic (Course Page) --- const enrollmentForm = document.getElementById('enrollmentForm'); if (enrollmentForm) { enrollmentForm.addEventListener('submit', function(e) { e.preventDefault(); const nameInput = document.getElementById('name').value; const emailInput = document.getElementById('email').value; console.log(`Enrollment Submitted for: ${nameInput} (${emailInput})`); // Simple success feedback alert(`Thank you, ${nameInput}! Your request for enrollment has been processed. We will contact you at ${emailInput} shortly with payment details.`); // Hide form after submission document.getElementById('enrollForm').style.display = 'none'; enrollmentForm.reset(); }); } // --- Simple Anchor Smooth Scrolling (for better UX across pages) --- document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function (e) { if (this.getAttribute('href') !== "#") { e.preventDefault(); const targetId = this.getAttribute('href').substring(1); const targetElement = document.getElementById(targetId); // Check if target exists on the current page if (targetElement) { window.scrollTo({ top: targetElement.offsetTop - 80, // Offset for fixed header behavior: 'smooth' }); } } }); }); }); |