Coding on Wix form.

Hi.
I’m using the wix forms, I added some code only for the input fields. Some simple Collapsed and expand. So all the code I wrote works fine. I have 0 lines of code for the submit button, i’m letting the wix form app do it’s own automation for the submission.
My problem is the submit button does not work. Nothing happens at all.
I have changed the ID of the submit button twice, in case.
I have called Wix support. The person said it was a code related problem and it’s being escalated to the coding team. But I cant wait 48h.

https://www.alphaveterans.ca/home

Any button on the site goes to the lightbox with the form.

Here is also my code.

export function Button1_click(event) {
if ($w(‘#wixForm1’).collapsed) {
$w(‘#wixForm1’).expand();
}
if ($w(‘#social’).collapsed) {
$w(‘#social’).expand();
}
if ($w(‘#therapeute’).expand) {
$w(‘#therapeute’).collapse();
}
if ($w(‘#pairaidant’).expand) {
$w(‘#pairaidant’).collapse();
}
if ($w(‘#harley’).expand) {
$w(‘#harley’).collapse();
}
if ($w(‘#textcover’).expand) {
$w(‘#textcover’).collapse();
}
if ($w(‘#infolettre’).expand) {
$w(‘#infolettre’).collapse();
}
if ($w(‘#hrd2kill’).expand) {
$w(‘#hrd2kill’).collapse();
}
if ($w(‘#repos’).expand) {
$w(‘#repos’).collapse();
}
if ($w(‘#salon’).expand) {
$w(‘#salon’).collapse();
}
if ($w(‘#dress’).expand) {
$w(‘#dress’).collapse();
}
if ($w(‘#textsocial’).collapsed) {
$w(‘#textsocial’).expand();
}
if ($w(‘#checkboxGroup2’).collapse) {
$w(‘#checkboxGroup2’).expand();
}
if ($w(‘#checkboxGroup3’).expand) {
$w(‘#checkboxGroup3’).collapse();
}
if ($w(‘#texttherapeute’).expand) {
$w(‘#texttherapeute’).collapse();
}
if ($w(‘#grostext’).expand) {
$w(‘#grostext’).collapse();
}
if ($w(‘#checkboxGroup4’).expand) {
$w(‘#checkboxGroup4’).collapse();
}
if ($w(‘#checkboxGroup5’).expand) {
$w(‘#checkboxGroup5’).collapse();
}
if ($w(‘#textsalon’).expand) {
$w(‘#textsalon’).collapse();
}
if ($w(‘#checkboxGroup1’).expand) {
$w(‘#checkboxGroup1’).collapse();
}
if ($w(‘#textdress’).expand) {
$w(‘#textdress’).collapse();
}

}
export function Button2_click(event) {
if ($w(‘#wixForms1’).collapsed) {
$w(‘#wixForms1’).expand();
}
if ($w(‘#social’).expand) {
$w(‘#social’).collapse();
}
if ($w(‘#therapeute’).collapsed) {
$w(‘#therapeute’).expand();
}
if ($w(‘#pairaidant’).expand) {
$w(‘#pairaidant’).collapse();
}
if ($w(‘#harley’).expand) {
$w(‘#harley’).collapse();
}
if ($w(‘#textcover’).expand) {
$w(‘#textcover’).collapse();
}
if ($w(‘#infolettre’).expand) {
$w(‘#infolettre’).collapse();
}
if ($w(‘#hrd2kill’).expand) {
$w(‘#hrd2kill’).collapse();
}
if ($w(‘#repos’).expand) {
$w(‘#repos’).collapse();
}
if ($w(‘#salon’).expand) {
$w(‘#salon’).collapse();
}
if ($w(‘#dress’).expand) {
$w(‘#dress’).collapse();
}
if ($w(‘#textsocial’).expand) {
$w(‘#textsocial’).collapse();
}
if ($w(‘#checkboxGroup2’).expand) {
$w(‘#checkboxGroup2’).collapse();
}
if ($w(‘#checkboxGroup3’).collapsed) {
$w(‘#checkboxGroup3’).expand();
}
if ($w(‘#texttherapeute’).collapsed) {
$w(‘#texttherapeute’).expand();
}
if ($w(‘#grostext’).expand) {
$w(‘#grostext’).collapse();
}
if ($w(‘#checkboxGroup4’).expand) {
$w(‘#checkboxGroup4’).collapse();
}
if ($w(‘#checkboxGroup5’).expand) {
$w(‘#checkboxGroup5’).collapse();
}
if ($w(‘#textsalon’).expand) {
$w(‘#textsalon’).collapse();
}
if ($w(‘#checkboxGroup1’).expand) {
$w(‘#checkboxGroup1’).collapse();
}
if ($w(‘#textdress’).expand) {
$w(‘#textdress’).collapse();
}
}
export function Button3_click(event) {
if ($w(‘#wixForms1’).collapsed) {
$w(‘#wixForms1’).expand();
}
if ($w(‘#pairaidant’).collapsed) {
$w(‘#pairaidant’).expand();
}
if ($w(‘#therapeute’).expand) {
$w(‘#therapeute’).collapse();
}
if ($w(‘#social’).expand) {
$w(‘#social’).collapse();
}
if ($w(‘#harley’).expand) {
$w(‘#harley’).collapse();
}
if ($w(‘#textcover’).expand) {
$w(‘#textcover’).collapse();
}
if ($w(‘#infolettre’).expand) {
$w(‘#infolettre’).collapse();
}
if ($w(‘#hrd2kill’).expand) {
$w(‘#hrd2kill’).collapse();
}
if ($w(‘#repos’).expand) {
$w(‘#repos’).collapse();
}
if ($w(‘#salon’).expand) {
$w(‘#salon’).collapse();
}
if ($w(‘#dress’).expand) {
$w(‘#dress’).collapse();
}
if ($w(‘#textsocial’).collapsed) {
$w(‘#textsocial’).expand();
}
if ($w(‘#checkboxGroup2’).expand) {
$w(‘#checkboxGroup2’).collapse();
}
if ($w(‘#checkboxGroup3’).expand) {
$w(‘#checkboxGroup3’).collapse();
}
if ($w(‘#texttherapeute’).expand) {
$w(‘#texttherapeute’).collapse();
}
if ($w(‘#grostext’).collapsed) {
$w(‘#grostext’).expand();
}
if ($w(‘#checkboxGroup4’).expand) {
$w(‘#checkboxGroup4’).collapse();
}
if ($w(‘#checkboxGroup5’).expand) {
$w(‘#checkboxGroup5’).collapse();
}
if ($w(‘#textsalon’).expand) {
$w(‘#textsalon’).collapse();
}
if ($w(‘#checkboxGroup1’).expand) {
$w(‘#checkboxGroup1’).collapse();
}
if ($w(‘#textdress’).expand) {
$w(‘#textdress’).collapse();
}
}
export function Button4_click(event) {
if ($w(‘#wixForms1’).collapsed) {
$w(‘#wixForms1’).expand();
}
if ($w(‘#social’).expand) {
$w(‘#social’).collapse();
}
if ($w(‘#therapeute’).expand) {
$w(‘#therapeute’).collapse();
}
if ($w(‘#pairaidant’).expand) {
$w(‘#pairaidant’).collapse();
}
if ($w(‘#textcover’).collapsed) {
$w(‘#textcover’).expand();
}
if ($w(‘#harley’).expand) {
$w(‘#harley’).collapse();
}
if ($w(‘#infolettre’).expand) {
$w(‘#infolettre’).collapse();
}
if ($w(‘#hrd2kill’).expand) {
$w(‘#hrd2kill’).collapse();
}
if ($w(‘#repos’).expand) {
$w(‘#repos’).collapse();
}
if ($w(‘#salon’).expand) {
$w(‘#salon’).collapse();
}
if ($w(‘#dress’).expand) {
$w(‘#dress’).collapse();
}
if ($w(‘#textsocial’).expand) {
$w(‘#textsocial’).collapse();
}
if ($w(‘#checkboxGroup2’).expand) {
$w(‘#checkboxGroup2’).collapse();
}
if ($w(‘#checkboxGroup3’).expand) {
$w(‘#checkboxGroup3’).collapse();
}
if ($w(‘#texttherapeute’).expand) {
$w(‘#texttherapeute’).collapse();
}
if ($w(‘#grostext’).collapsed) {
$w(‘#grostext’).expand();
}
if ($w(‘#checkboxGroup4’).expand) {
$w(‘#checkboxGroup4’).collapse();
}
if ($w(‘#checkboxGroup5’).expand) {
$w(‘#checkboxGroup5’).collapse();
}
if ($w(‘#textsalon’).expand) {
$w(‘#textsalon’).collapse();
}
if ($w(‘#checkboxGroup1’).expand) {
$w(‘#checkboxGroup1’).collapse();
}
if ($w(‘#textdress’).expand) {
$w(‘#textdress’).collapse();
}
}
export function Button5_click(event) {
if ($w(‘#wixForms1’).collapsed) {
$w(‘#wixForms1’).expand();
}
if ($w(‘#social’).expand) {
$w(‘#social’).collapse();
}
if ($w(‘#therapeute’).expand) {
$w(‘#therapeute’).collapse();
}
if ($w(‘#pairaidant’).expand) {
$w(‘#pairaidant’).collapse();
}
if ($w(‘#harley’).collapsed) {
$w(‘#harley’).expand();
}
if ($w(‘#textcover’).expand) {
$w(‘#textcover’).collapse();
}
if ($w(‘#infolettre’).expand) {
$w(‘#infolettre’).collapse();
}
if ($w(‘#hrd2kill’).expand) {
$w(‘#hrd2kill’).collapse();
}
if ($w(‘#repos’).expand) {
$w(‘#repos’).collapse();
}
if ($w(‘#salon’).expand) {
$w(‘#salon’).collapse();
}
if ($w(‘#dress’).expand) {
$w(‘#dress’).collapse();
}
if ($w(‘#textsocial’).collapsed) {
$w(‘#textsocial’).expand();
}
if ($w(‘#checkboxGroup2’).expand) {
$w(‘#checkboxGroup2’).collapse();
}
if ($w(‘#checkboxGroup3’).expand) {
$w(‘#checkboxGroup3’).collapse();
}
if ($w(‘#texttherapeute’).expand) {
$w(‘#texttherapeute’).collapse();
}
if ($w(‘#grostext’).expand) {
$w(‘#grostext’).collapse();
}
if ($w(‘#checkboxGroup4’).collapsed) {
$w(‘#checkboxGroup4’).expand();
}
if ($w(‘#checkboxGroup5’).expand) {
$w(‘#checkboxGroup5’).collapse();
}
if ($w(‘#textsalon’).expand) {
$w(‘#textsalon’).collapse();
}
if ($w(‘#checkboxGroup1’).expand) {
$w(‘#checkboxGroup1’).collapse();
}
if ($w(‘#textdress’).expand) {
$w(‘#textdress’).collapse();
}
}
export function Button6_click(event) {
if ($w(‘#wixForms1’).collapsed) {
$w(‘#wixForms1’).expand();
}
if ($w(‘#social’).expand) {
$w(‘#social’).collapse();
}
if ($w(‘#therapeute’).expand) {
$w(‘#therapeute’).collapse();
}
if ($w(‘#pairaidant’).expand) {
$w(‘#pairaidant’).collapse();
}
if ($w(‘#harley’).expand) {
$w(‘#harley’).collapse();
}
if ($w(‘#textcover’).expand) {
$w(‘#textcover’).collapse();
}
if ($w(‘#infolettre’).collapsed) {
$w(‘#infolettre’).expand();
}
if ($w(‘#hrd2kill’).expand) {
$w(‘#hrd2kill’).collapse();
}
if ($w(‘#repos’).expand) {
$w(‘#repos’).collapse();
}
if ($w(‘#salon’).expand) {
$w(‘#salon’).collapse();
}
if ($w(‘#dress’).expand) {
$w(‘#dress’).collapse();
}
if ($w(‘#textsocial’).collapsed) {
$w(‘#textsocial’).expand();
}
if ($w(‘#checkboxGroup2’).expand) {
$w(‘#checkboxGroup2’).collapse();
}
if ($w(‘#checkboxGroup3’).expand) {
$w(‘#checkboxGroup3’).collapse();
}
if ($w(‘#texttherapeute’).expand) {
$w(‘#texttherapeute’).collapse();
}
if ($w(‘#grostext’).expand) {
$w(‘#grostext’).collapse();
}
if ($w(‘#checkboxGroup4’).expand) {
$w(‘#checkboxGroup4’).collapse();
}
if ($w(‘#checkboxGroup5’).expand) {
$w(‘#checkboxGroup5’).collapse();
}
if ($w(‘#textsalon’).expand) {
$w(‘#textsalon’).collapse();
}
if ($w(‘#checkboxGroup1’).expand) {
$w(‘#checkboxGroup1’).collapse();
}
if ($w(‘#textdress’).expand) {
$w(‘#textdress’).collapse();
}
}
export function Button7_click(event) {
if ($w(‘#wixForms1’).collapsed) {
$w(‘#wixForms1’).expand();
}
if ($w(‘#social’).expand) {
$w(‘#social’).collapse();
}
if ($w(‘#therapeute’).expand) {
$w(‘#therapeute’).collapse();
}
if ($w(‘#pairaidant’).expand) {
$w(‘#pairaidant’).collapse();
}
if ($w(‘#harley’).expand) {
$w(‘#harley’).collapse();
}
if ($w(‘#textcover’).expand) {
$w(‘#textcover’).collapse();
}
if ($w(‘#infolettre’).expand) {
$w(‘#infolettre’).collapse();
}
if ($w(‘#hrd2kill’).collapsed) {
$w(‘#hrd2kill’).expand();
}
if ($w(‘#repos’).expand) {
$w(‘#repos’).collapse();
}
if ($w(‘#salon’).expand) {
$w(‘#salon’).collapse();
}
if ($w(‘#dress’).expand) {
$w(‘#dress’).collapse();
}
if ($w(‘#textsocial’).collapsed) {
$w(‘#textsocial’).expand();
}
if ($w(‘#checkboxGroup2’).expand) {
$w(‘#checkboxGroup2’).collapse();
}
if ($w(‘#checkboxGroup3’).expand) {
$w(‘#checkboxGroup3’).collapse();
}
if ($w(‘#texttherapeute’).expand) {
$w(‘#texttherapeute’).collapse();
}
if ($w(‘#grostext’).expand) {
$w(‘#grostext’).collapse();
}
if ($w(‘#checkboxGroup4’).expand) {
$w(‘#checkboxGroup4’).collapse();
}
if ($w(‘#checkboxGroup5’).collapsed) {
$w(‘#checkboxGroup5’).expand();
}
if ($w(‘#textsalon’).expand) {
$w(‘#textsalon’).collapse();
}
if ($w(‘#checkboxGroup1’).expand) {
$w(‘#checkboxGroup1’).collapse();
}
if ($w(‘#textdress’).expand) {
$w(‘#textdress’).collapse();
}
}
export function Button8_click(event) {
if ($w(‘#wixForms1’).collapsed) {
$w(‘#wixForms1’).expand();
}
if ($w(‘#social’).expand) {
$w(‘#social’).collapse();
}
if ($w(‘#therapeute’).expand) {
$w(‘#therapeute’).collapse();
}
if ($w(‘#pairaidant’).expand) {
$w(‘#pairaidant’).collapse();
}
if ($w(‘#harley’).expand) {
$w(‘#harley’).collapse();
}
if ($w(‘#textcover’).expand) {
$w(‘#textcover’).collapse();
}
if ($w(‘#infolettre’).expand) {
$w(‘#infolettre’).collapse();
}
if ($w(‘#hrd2kill’).expand) {
$w(‘#hrd2kill’).collapse();
}
if ($w(‘#repos’).collapsed) {
$w(‘#repos’).expand();
}
if ($w(‘#salon’).expand) {
$w(‘#salon’).collapse();
}
if ($w(‘#dress’).expand) {
$w(‘#dress’).collapse();
}
if ($w(‘#textsocial’).collapsed) {
$w(‘#textsocial’).expand();
}
if ($w(‘#checkboxGroup2’).expand) {
$w(‘#checkboxGroup2’).collapse();
}
if ($w(‘#checkboxGroup3’).expand) {
$w(‘#checkboxGroup3’).collapse();
}
if ($w(‘#texttherapeute’).expand) {
$w(‘#texttherapeute’).collapse();
}
if ($w(‘#grostext’).collapsed) {
$w(‘#grostext’).expand();
}
if ($w(‘#checkboxGroup4’).expand) {
$w(‘#checkboxGroup4’).collapse();
}
if ($w(‘#checkboxGroup5’).expand) {
$w(‘#checkboxGroup5’).collapse();
}
if ($w(‘#textsalon’).expand) {
$w(‘#textsalon’).collapse();
}
if ($w(‘#checkboxGroup1’).expand) {
$w(‘#checkboxGroup1’).collapse();
}
if ($w(‘#textdress’).expand) {
$w(‘#textdress’).collapse();
}
}
export function Button9_click(event) {
if ($w(‘#wixForms1’).collapsed) {
$w(‘#wixForms1’).expand();
}
if ($w(‘#social’).expand) {
$w(‘#social’).collapse();
}
if ($w(‘#therapeute’).expand) {
$w(‘#therapeute’).collapse();
}
if ($w(‘#pairaidant’).expand) {
$w(‘#pairaidant’).collapse();
}
if ($w(‘#harley’).expand) {
$w(‘#harley’).collapse();
}
if ($w(‘#textcover’).expand) {
$w(‘#textcover’).collapse();
}
if ($w(‘#infolettre’).expand) {
$w(‘#infolettre’).collapse();
}
if ($w(‘#hrd2kill’).expand) {
$w(‘#hrd2kill’).collapse();
}
if ($w(‘#repos’).expand) {
$w(‘#repos’).collapse();
}
if ($w(‘#salon’).collapsed) {
$w(‘#salon’).expand();
}
if ($w(‘#dress’).expand) {
$w(‘#dress’).collapse();
}
if ($w(‘#textsocial’).expand) {
$w(‘#textsocial’).collapse();
}
if ($w(‘#checkboxGroup1’).expand) {
$w(‘#checkboxGroup1’).collapse();
}
if ($w(‘#checkboxGroup2’).expand) {
$w(‘#checkboxGroup2’).collapse();
}
if ($w(‘#checkboxGroup3’).expand) {
$w(‘#checkboxGroup3’).collapse();
}
if ($w(‘#texttherapeute’).expand) {
$w(‘#texttherapeute’).collapse();
}
if ($w(‘#grostext’).collapsed) {
$w(‘#grostext’).expand();
}
if ($w(‘#checkboxGroup4’).expand) {
$w(‘#checkboxGroup4’).collapse();
}
if ($w(‘#checkboxGroup5’).expand) {
$w(‘#checkboxGroup5’).collapse();
}
if ($w(‘#textsalon’).collapsed) {
$w(‘#textsalon’).expand();
}
if ($w(‘#textdress’).expand) {
$w(‘#textdress’).collapse();
}
}
export function Button10_click(event) {
if ($w(‘#wixForms1’).collapsed) {
$w(‘#wixForms1’).expand();
}
if ($w(‘#social’).expand) {
$w(‘#social’).collapse();
}
if ($w(‘#therapeute’).expand) {
$w(‘#therapeute’).collapse();
}
if ($w(‘#pairaidant’).expand) {
$w(‘#pairaidant’).collapse();
}
if ($w(‘#harley’).expand) {
$w(‘#harley’).collapse();
}
if ($w(‘#textcover’).expand) {
$w(‘#textcover’).collapse();
}
if ($w(‘#infolettre’).expand) {
$w(‘#infolettre’).collapse();
}
if ($w(‘#hrd2kill’).expand) {
$w(‘#hrd2kill’).collapse();
}
if ($w(‘#repos’).expand) {
$w(‘#repos’).collapse();
}
if ($w(‘#salon’).expand) {
$w(‘#salon’).collapse();
}
if ($w(‘#dress’).collapsed) {
$w(‘#dress’).expand();
}
if ($w(‘#textsocial’).collapsed) {
$w(‘#textsocial’).expand();
}
if ($w(‘#checkboxGroup1’).collapsed) {
$w(‘#checkboxGroup1’).expand();
}
if ($w(‘#checkboxGroup2’).expand) {
$w(‘#checkboxGroup2’).collapse();
}
if ($w(‘#checkboxGroup3’).expand) {
$w(‘#checkboxGroup3’).collapse();
}
if ($w(‘#texttherapeute’).expand) {
$w(‘#texttherapeute’).collapse();
}
if ($w(‘#grostext’).expand) {
$w(‘#grostext’).collapse();
}
if ($w(‘#checkboxGroup4’).expand) {
$w(‘#checkboxGroup4’).collapse();
}
if ($w(‘#checkboxGroup5’).expand) {
$w(‘#checkboxGroup5’).collapse();
}
if ($w(‘#textsalon’).expand) {
$w(‘#textsalon’).collapse();
}
if ($w(‘#textdress’).collapsed) {
$w(‘#textdress’).expand();
}
}
Any help is appreciated.

Thx!

First, when you’re checking if an element has .expand, it’s going to be true always. You’re basically checking whether it has the capacity to expand, not whether it is expanded. You can use the not syntax to check that the element is not .collapsed :

if (!$w('#id").collapsed)

Not sure which one is meant to be your submit button, but it might be better to use code to ensure submit. Also, because I’m having an OCD spike, here’s a much neater way of writing your code :slight_smile:

const elems_to_collapse = [
    'wixForms1',
    'social',
    'therapeute',
    //add as needed
],
elems_to_expand = [
    'textdress',
    'textsalon',
    //add as needed
];

export function submit_click() {
    Promise.all([
    //Promise.all ensures an array [] of actions are completed
    elems_to_collapse.forEach(el => {
        if (!$w(`#${el}`).collapsed) $w(`#${el}`).collapse();
    }),
    //action 1 is to collapse elements_to_collapse
    elems_to_expand.forEach(el => {
        if ($w(`#${el}`).collapsed) $w(`#${el}`).expand();
    }),
    //action 2 is to expand elements_to_expand
    $w('#dataset').save()
    //action 3 is to save the data in the form's dataset
    ]).then(() => console.log("saved"))
    //if it works, console will print "saved"
    .catch(e => console.error(e));    
    //if it doesn't, console will display the error
}

Thx David for the response.
I know the coding is awful, it’s my first time, I watch a tutorial and made it work on my website.
in response to what you said, I do not have code for the submit button. I’m letting the Wix APP form do it’s automation.
There’s no reason for the submit button to not work… it’s automated from the App.
Now for this part
export function submit_click() {
Promise.all([
elems_to_collapse.forEach(el => {
if (!$w(#${el}).collapsed) $w(#${el}).collapse();
}),
elems_to_expand.forEach(el => {
if ($w(#${el}).collapsed) $w(#${el}).expand();
}),
$w(‘#dataset’).save()
]).then(() => console.log(“saved”))
.catch(e => console.error(e));
}

Can you explain what it does?
thx!

You will want to make sure that you add the link to refer back to your same post from yesterday where you show the picture of the submit button being through your Wix Forms app.
https://www.wix.com/corvid/forum/community-discussion/form-not-submitting-when-pressing-on-submit-button

As you submit your form through the submit button on the Wix Forms app there is nothing you can do in code to make this work or not work, you will have to wait until somebody from the Wix Forms team can address this issue and fix this for you.

However, you can do what David has shown you above and make up your own user input form instead of using the Wix Forms app and use code as you have already and then add your own submit button or use code to save it instead.

See here for creating a user input form with a submit button.
https://support.wix.com/en/article/creating-a-form-with-user-input-elements
https://support.wix.com/en/article/adding-a-submit-button-to-your-form

See here for the Wix Data API and the Save function.
https://www.wix.com/corvid/reference/wix-data.html#save

Finally, please make sure that you check the Forum Guidelines and take note of using the code block for formatting your code in (like David has done in his reply) and about duplicate posts.

I added some comments to the original post to explain what each part of the code does!

@skmedia thx!. I took someone advice and did the forms from scratch. Instead of the premade /automated forms from Wix. Everything works, except the automation of emails. I want to receive an email of the form that was submit. The explanation on the wix website for Wix Data Form Automation, it shows only for 1 form submitted. I have multiple forms. I can make it work with 1 form. But when I choose the option “all forms on website” , nothing works.

@alphaveteranwebsite Sending automated emails in code requires this other API:
https://www.wix.com/corvid/reference/wix-crm.html#emailContact

I think there’s an example up top