tag)
document.addEventListener('DOMContentLoaded', function() {
const form = document.getElementById('demoForm');
// Add hidden input for page URL if it doesn't exist
if (!document.getElementById('page_url')) {
const pageUrlInput = document.createElement('input');
pageUrlInput.type = 'hidden';
pageUrlInput.name = 'page_url';
pageUrlInput.id = 'page_url';
form.appendChild(pageUrlInput);
}
// Set the current page URL when form loads
document.getElementById('page_url').value = window.location.href;
// Also update on form submission (in case of SPA navigation)
form.addEventListener('submit', function() {
document.getElementById('page_url').value = window.location.href;
});
});