Using Submit button in form to email results

Hi there,
I am creating a form in WixCode for my client which needs to do the following:

  1. Navigate to a light box that thanks the user when submission is successful.
  2. Submit an email to the owner with the answers to the questionaire

Navigation to the lightbox link works fine, For the 2nd requirement I followed the instructions from this article:Velo Tutorial: Sending an Email on Form Submission | Help Center | Wix.com

and pasted the code, and modified it somewhat to reflect the form. The one thing I am fuzzy on is how to link the event handler to the submission button. I am aware that the correct field name are not yet entered into the event handler code, but I would first like to link the submit button to the code and then I can figure out the rest. Here is the link to the page:
vamiksroom.com/temporary
Thanks in advance.
Bill

Hi Bill,
To hook up events to elements, use the properties panel (If the panel isn’t open, right click on the element and select ‘view properties’).
Here’s an example of how to use it - Tutorial: Changing the Text Label of a Button with Code | Help Center | Wix.com

Hi Uval,
Thanks for your reply. I went through the article you sent me and have since played around with the code. I am not clear however, how to link the button to the event handler. I have attached a screenshot of this as well as the 2 jscript modules.
To reiterate, What I am trying to do is have the submit button send an email to the owner of the site that contains all the info that the user filled out on the form, so I am hoping I did the 2 modules correctly.

Also on that subject, in the code where I indicate the data in which the owner wants to receive, ie, #textInput1, etc., do I need to indicate each field name or can I do it by grouped fields, ie, #group1, etc. ?
Thanks
Bill

Website page: Vamiksroom.com/temporary

Hi Bill,
Actually, I now see that your intended trigger for sending the email is the dataset’s onAfterSave event, which is fantastic - that’s exactly how it should be. Row #5 in your page code tells the system to call the function sendFormData when the onAfterSave event is triggered.
But… it seems you got your dataset id wrong. Where you have “Screening_requests dataset 2”, you should be supplying the id of the dataset, not its display name. To find out what the id is (or change it), select it in the editor, and go to its property panel.

Another important note - you accidentally exposed your sendgrid API key in the code you pasted. You need to change it ASAP so that nobody else can use it.

Uval
Thanks for your help so far. The API key was actually copied from the sample jscript in the forum. That was another question I had - whether I need to have a unique key in the jscript. Now that I know they are unique, how do I set my API key?

Also in the event Handler could you tell me whether it’s connected correctly to the submit button?

I did a google search for Sendgrid API question. My question is do I or the client need to have a paid monthly sendgrid account?

Their free service is usually enough for most, but you need to decide for yourself:

btw, they have some process for verifying your domain which will help you prevent the emails from going to
the spam folder. I’m not very familiar with it myself, but you should look into it.

I changed the API keys. Form is still not sending to owner of site. Is there’s something else that is missing from the event handler? As you can see I am pretty new to code. Thanks

What is the syntax I need to be entering in order to get this button to work?