Jump to content

Send to a different email address depending on answer to drop down field

Recommended Posts

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?

document.addEventListener('DOMContentLoaded', function() {
  const form = document.querySelector('form');
  form.addEventListener('submit', function(event) {
    const dropdownField = form.querySelector('#select-72b10c59-83f1-44f1-8e11-02bb2c29c214-field');
    const selectedOption = dropdownField.value;
    let emailAddress;
    switch (selectedOption) {
      case 'Media':
        emailAddress = 'email1';
      case 'Other':
        emailAddress = 'email2';
      case 'General Enquiry':
        emailAddress = 'email3';
        emailAddress = 'email3';
    form.action = 'mailto:' + emailAddress;
Link to comment
  • Replies 0
  • Views 1.1k
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.