Form submit button not working on live website

Hi!

I made a form with Corvid which you can see at the following address:
https://www.bhenv.fr/isolation

All is working well when I’m testing with Wix editor preview mode => when I click the submit button at the end, the datas are saved in the database board, the email is sent and the visitor is redirected on the chosen page.

But on the live version nothing happens when I click on the button.

Here is my code if it can be of any help:

import wixCRM from 'wix-crm';
import wixLocation from 'wix-location';
import wixData from 'wix-data';
import wixUsers from 'wix-users';
import {sendEmail} from 'backend/email';

//clicked buttons datas

let userId = wixUsers.currentUser.id;
$w.onReady(() => {
let toSave = { _id: userId };
$w("#button3, #button4, #button5, #button6, #button7, #button8, #button9, #button10, #button11, #button12, #button13, #button14, #button15, #button16, #button17, #button18, #button19, #button20, #button21, #button22, #button23").onClick(event => {
switch (event.target.id) {
case "button3":
toSave.maisonIndividuelle = "oui";
$w('#group4').hide();
$w('#group5').show();
break;
case "button4":
toSave.maisonIndividuelle = "non";
break;
case "button5":
toSave.pieceAIsoler = "Combles et grenier";
$w('#group5').hide();
$w('#group6').show();
break;
case "button6":
toSave.pieceAIsoler = "Sous-sol et cave";
$w('#group5').hide();
$w('#group6').show();
break;
case "button7":
toSave.pieceAIsoler = "Garage";
$w('#group5').hide();
$w('#group6').show();
break;
case "button8":
toSave.pieceAIsoler = "Toute ma maison";
$w('#group5').hide();
$w('#group6').show();
break;
case "button9":
toSave.foyer = "1";
$w('#group6').hide();
$w('#group7').show();
break;
case "button10":
toSave.foyer = "2";
$w('#group6').hide();
$w('#group7').show();
break;
case "button11":
toSave.foyer = "3";
$w('#group6').hide();
$w('#group7').show();
break;
case "button12":
toSave.foyer = "4";
$w('#group6').hide();
$w('#group7').show();
break;
case "button13":
toSave.foyer = "5 et +";
$w('#group6').hide();
$w('#group7').show();
break;
case "button14":
toSave.revenuAnnuel = "- de 19 074€";
$w('#group7').hide();
$w('#group8').show();
break;
case "button15":
toSave.revenuAnnuel = "19 074€-27 896€";
$w('#group7').hide();
$w('#group8').show();
break;
case "button16":
toSave.revenuAnnuel = "27 896€-33 547€";
$w('#group7').hide();
$w('#group8').show();
break;
case "button17":
toSave.revenuAnnuel = "33 547€-39 192€";
$w('#group7').hide();
$w('#group8').show();
break;
case "button18":
toSave.revenuAnnuel = "39 192€-44 860";
$w('#group7').hide();
$w('#group8').show();
break;
case "button19":
toSave.revenuAnnuel = "+ de 44 860€";
$w('#group7').hide();
$w('#group8').show();
break;
case "button20":
toSave.m2 = "-50m2";
$w('#group8').hide();
$w('#group9').show();
break;
case "button21":
toSave.m2 = "50-100m2";
$w('#group8').hide();
$w('#group9').show();
break;
case "button22":
toSave.m2 = "100-200m2";
$w('#group8').hide();
$w('#group9').show();
break;
case "button23":
toSave.m2 = "+200m2";
$w('#group8').hide();
$w('#group9').show();
break;
}
})

//submit, save and send

$w("#button24").onClick(event => {
toSave.nom = $w("#input1").value;
toSave.prenom = $w("#input2").value;
toSave.cp = $w("#input5").value;
toSave.tel = $w("#input6").value;

let subject = `Nouveau lead : ${$w("#input1").value}`;
let body = `Informations du lead :
Nom : ${$w("#input1").value}
Prénom : ${$w("#input2").value}
Code postal : ${$w("#input5").value}
Téléphone : ${$w("#input6").value}`;

wixData.save("OneClickForm", toSave)
.then(() => sendEmail(subject, body))
.then(() => wixLocation.to("/formulaire-valide"));
})
})

Hi … check your database permissions. You either have them set to Admin or Member only. If Admin, it works in editor because you are an Admin. If Member, it works in editor because you are logged in so therefor user must also be logged in before they are allowed to submit.

Hi! Thanks for your reply but it does not seem that the issue comes from here.
Here are the permissions set:

Reading content : Anyone
Creating content : Anyone
Updating content : Anyone
Deleting content : Admin

Not sure if it can help but I created 2 forms on the website:
The first one (with submit button issue) at the following link: https://www.bhenv.fr/isolation
The second one at the following link: https://www.bhenv.fr/demande-isolation

The second one is working fine both on preview mode and on live website.

Here is its code (maybe it creates some conflicts with the first form and I should create separated database boards for each form?):

import wixCRM from 'wix-crm';
import wixLocation from 'wix-location';
import wixData from 'wix-data';
import wixUsers from 'wix-users';
import {sendEmail} from 'backend/email';

let userId = wixUsers.currentUser.id;
$w.onReady(() => {
let toSave = {_id: userId};
$w("#button3, #button4").onClick(event => {
switch(event.target.id){
case "button3":
toSave.maisonIndividuelle = "oui";
$w('#group4').hide();
$w('#group9').show();
break;
}

$w("#dataset1").onAfterSave(sendFormData);
});
//email notification
function sendFormData() {
const subject = `Nouveau lead : ${$w("#input1").value}`;
const body = `Informations du lead :
Nom : ${$w("#input1").value}
Prénom : ${$w("#input2").value}
Code postal : ${$w("#input5").value}
Téléphone : ${$w("#input6").value}`;

sendEmail(subject, body)
.then(response => console.log(response));
}
})

@code-queen No more idea on the issue?

@yisrael-wix Any help on that one? Seems no one can find where those differences between preview and live mode are coming from.