Baguettely Posted October 29, 2023 Share Posted October 29, 2023 I want a Squarespace form to be sent to a different email address depending on whether they select "Media", "General Enquiries", or "Other" in a drop down field for the contact type. I have written the following code and put it into page header code but it still won't run. Does anyone know what would fix this? <script> document.addEventListener('DOMContentLoaded', function() { const form = document.querySelector('form'); form.addEventListener('submit', function(event) { event.preventDefault(); const dropdownField = form.querySelector('#select-72b10c59-83f1-44f1-8e11-02bb2c29c214-field'); const selectedOption = dropdownField.value; let emailAddress; switch (selectedOption) { case 'Media': emailAddress = 'email1'; break; case 'Other': emailAddress = 'email2'; break; case 'General Enquiry': emailAddress = 'email3'; break; default: emailAddress = 'email3'; } form.action = 'mailto:' + emailAddress; form.submit(); }); }); </script> Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment