ID of wixForms... not a valid selector

Hi All,

I have a wix form, it seems to have two IDs $w( ‘#wixForms1’ ) and $w( ‘#form1’ ) and both of these in the page code give “is not a valid selector”. I realise I’m doing something rookie but a decent amount of searching has turned up zero.

I am looking for a form.OnSubmit() or .OnSave(). While googling I’ve seen dataset.OnAfterSave() but I don’t appear to have a dataset.

Bigger picture, this is an appointment booking form and what I am trying to accomplish is to generate two emails on a single form submit, one to my customer, and one to the relevant store manager (store email is held as a value of the store drop down). I set up one automation that works fine for the customer, but I can’t see how to make a second automation that takes the email from the store drop down and notifies the store. I thought ok, lets just sidestep the complex part, I’ll just make a second hidden form that clones the values of the first and launches a new automation to email the store.

regards,
Dave

Hi Dave,

For sending emails after a form submission you will probably find this article helpful.

Corvid Tutorial: Sending an Email on Form Submission

Regarding the issue with the form IDs could you send us a snippet of your code and a link to your site, so we can take a closer look?

There is no form onSubmit function but you could use the submit buttons onClick() function.

Hope this helps!

Dara | Corvid Team

Hi Dara,

Thanks for getting back to me, my site is https://camille830.wixsite.com/website-1/bookings

I’ve read through this example before and it’s using a 3rd party API and the email body will be ugly text. I’d much prefer to send emails from wix automations which has the nice email templates. (I also tried Triggered emails but that seems to require the email addresses to be in the members table)

To recreate
Add > Contacts & Forms > Contact Form
now in the page code try and reference it the same way any other element is addressed
$w( ‘#wixForms1’ ) → not a valid selector
$w(‘#form1’) → not a valid selector

Do I need to bind the form to a dataset and then address the dataset instead of the form?

I am using the submitButton.onClick() now to grab the values, but it probably fires pre-form validation which isn’t great. Dataset.OnBeforeSave() might do it post validation. I’d still need a way to programatically submit the second form though.

thanks,
Dave

Hi Dave,

When setting up an automation to send a notification about a form submission you can only choose one email address to send it to. If you want to send an email to a certain email address depending on a dropdown value you will have to use a 3rd party API. Triggered emails can only be sent to currently logged-in users so that also won’t work.

I tried to recreate your issue with the form IDs, but I am unable, when I add them to your code they are both valid selectors.

Data binding and coding is not necessary, we do not recommend having both data binding and code added to the same elements.

I noticed the onClick() function you set it is just taking the values of the input fields and adding them to different input fields.


If you are trying to take the values of the form submission and add them to a database collection you will have to use the insert() function from the wix-data API.

Hope this helps!

Dara | Corvid Team

Hi Dara,

After closing/restarting my browser the ‘not a valid selector’ has gone away. Fantastic. We are getting closer. I can now add in the event handler for the form1 submission.

So now all that remains is submitting form2 programatically. I can’t see anything on the button2 or form2 selectors that lets me submit programatically. Is there a way?

thanks,
Dave