Wix form combined with my own code... some problems

Hye, I have a form for subscription with a submit button. I used a subscription form made by wix (?).

1.When I attach a onClick function (using the properties panel) sometimes it gives me button_click function and other times - button_click_1.
What is the different?

  1. when I made the form I have connected it to update a database and send me an email. Now I have added some code and backend code (for using a webhook etc). I have notice that sometimes it doesn’t update the database at Wix and then I don’t recieve a mail, but the webhook does work always. Is it because I actually connected 2 actions to the button? (the form update and my manually code?) so it skips the wix code and “prefers” my own code sometimes? (I hope you understand me…)

  2. I guess that is - again - some back code of the form that I can’t reach: when a user insert invalid data to a field and press the submit button, I don’t let the onClick function to action. Just give the user a “Invalid…” and wait for him to insert correct value. It works fine, but what also happens is that all the fields at the form get empty. I don’t want it to happen, of course. Just let the user fix the value at a specific field and keep all his other values as he has inserted. Is it possible or that’s because I am using a prepared-form?

Tnx for any help :slight_smile:

tnx

Simple, don’t use Wix Forms as that is a Wix app which automates a lot of the workings for you, hence you can’t get everything to work when you combine Wix Forms with Wix Code.

You are much better suited doing your own user input forms through Wix Code entirely and you will full control over everything that you do with it.

https://support.wix.com/en/corvid-by-wix/basics
https://www.wix.com/corvid/reference
https://www.wix.com/corvid/examples

thanks for answering. I guess you right, I will do it.

What about my first question - any idea? I couldn’t find any clue

@avitaltry

1.When I attach a onClick function (using the properties panel) sometimes it gives me button_click function and other times - button_click_1.
What is the different?

There is no difference, it basically all depends on what the id name of the element that you are adding the onClick event handler to is through the properties panel for it.
https://support.wix.com/en/article/corvid-working-with-the-properties-panel
https://support.wix.com/en/article/how-to-change-the-text-label-of-a-button-with-events
https://support.wix.com/en/article/corvid-reacting-to-user-actions-using-events

So if you have changed the button id on your first button from say button1 to firstButton, then when you add the onClick through the properties panel it will automatically put it in your code as

 export function firstButton_onClick(event) {

Don’t worry if your code doesn’t show the onClick and just shows click instead, just a newer way of doing the event handler in the code on your page.

It is always best to change the elements id name to something that corresponds with what it is being used for instead of leaving all your elements as text1 to text100 or button 1 to button 100.

That way it is easier for you to be able to find the needed element on your page and you can easily write into your code the appropriate id name for that element instead of having to keep referring back to your page to check what the button number or the text box number was for example.

@givemeawhisky Thank you!!!