Custom Contact Form Recipient Selection

I have designed the form I want, but WIX is much more difficult for me to navigate than Prestashop was. My contact form has a dropdown to select the recipient. I have connected my form fields to CMS. I know that I need to add code so that the selected value from the dropdown can determine the destination email address. I have 4 choices so for my purposes, it would look like this:
Custom Contact Code

Does this go under $w.onReady(function () { in the sendEmail.jsw or does it go in the onChange() event handler for the dropdown? The thread Contact Form (Multiple Addresses) shows both.

What else am I missing to make this function? Any help would be very much appreciated. I’ve done minor coding in Prestashop, but WIX is super confusing to me. Anything I have been able to find on it for WIX either the links don’t work anymore or there isn’t enough information for me to finish it.
I tried attaching a screen of my custom form, but apparently new users can only add one image.

Whenever you submit data to a collection on Wix there are usually two approaches:

  • Using code to programmatically submit content to a collection
  • Using the visual editor to connect form fields to the collection/associated fields

Since you have connected the form fields to the CMS using the editor, you can take advantage of the Dropdown elements ability to have a value for each choice. While the label is what the user will see displayed, the value is what will actually be saved in the collection associated to the form.

You can edit the value for each choice by clicking on the following:

Select the Dropdown Element > “Manage Choices” > “Edit Value”

If you would like to submit the data to the collection using code, the code snippet you posted becomes more relevant. Where you place your code depends on how you want to store the users data as they fill out the form.

One common approach would be to perform validations and operations on the form data once the user submits the entire form. In this case, your code would go inside of a onClick() handler for the contact form’s submission button.

1 Like

Hi Thomas,

Thank you so much for the tip on the edit value. I totally missed that. I went back in and added the value, but it still does not send to the email. When I run a test it shows up in my CMS dashboard, but it never reaches the destination email. Is there anything else that you can suggest?