document.addEventListener('DOMContentLoaded', function() { // Function to handle donation function handleDonation(amount, recurring) { var url = `https://forerunnermentoring.churchcenter.com/giving?default_amount=${amount}`; if (recurring) { url += '&recurring=true'; // Adjust this based on Planning Center's requirements } window.location.href = url; } // Event listener for preset amounts document.querySelectorAll('.donation-amount').forEach(function(button) { button.addEventListener('click', function(e) { e.preventDefault(); var amount = this.getAttribute('data-amount'); var recurring = document.getElementById('recurring').checked; handleDonation(amount, recurring); }); }); // Event listener for custom amount button document.getElementById('custom-donate').addEventListener('click', function() { var amount = document.getElementById('custom-amount').value; if (amount && !isNaN(amount)) { var recurring = document.getElementById('recurring').checked; handleDonation(amount, recurring); } else { alert('Please enter a valid amount.'); } }); });