My site is working fine in preview mode, but on live the submit button doesn’t write anything to my database (for both the homepage and the contact us form).
I see this is a recurring issue with Wix; if anyone has any insight would be much appreciated.
Live site link: https://anikajhalani.wixsite.com/website-4/books
Here is the code for my ‘submit’ function on the homepage (all the UI is working fine, but nothing is being written to my database):
export function submitFormButton_click(event) {
$w(‘#submitFormButton’).hide(‘roll’)
$w(‘#submitMessage’).show(‘roll’)
$w(‘#booksButton’).show(‘roll’)
let inputArray = ;
for ( let i = 1; i <= 3; i++) {
let inputData = {
title: $w(‘#bookInput’ + i).value,
bookStyle: $w(‘#bookStyle’ + i).value,
bookStyleText: JSON.stringify($w(‘#bookStyle’ + i).value),
bookSubject: $w(‘#bookSubject’ + i).value,
bookSubjectText: JSON.stringify($w(‘#bookSubject’ + i).value),
bookGeo: $w(‘#bookGeo’ + i).value,
bookGeoText: JSON.stringify($w(‘#bookGeo’ + i).value),
bookCharacter: $w(‘#bookChar’ + i).value,
bookCharacterText: JSON.stringify($w(‘#bookChar’ + i).value),
bookTime: $w(‘#bookTime’ + i).value,
bookTimeText: JSON.stringify($w(‘#bookTime’ + i).value),
bookForm: $w(‘#bookForm’ + i).value,
bookFormText: JSON.stringify($w(‘#bookForm’ + i).value),
bookCountry: $w(‘#country’ + i).value,
userTags:$w(‘#userTags’ + i).value,
bookNumber: i,
};
inputArray.push(inputData);
}
console.log(inputArray);
let collection = ‘bookInfo’;
wixData.bulkInsert(collection, inputArray)
.then( (results) => {
let ids = results.insertedItemIds; //see item below
console.log(ids);
for ( let i = 1; i <= 3; i++) {
insertSubjectReferences(ids[i - 1], $w(‘#bookSubject’ + i).value)
insertStyleReferences(ids[i - 1], $w(‘#bookStyle’ + i).value)
insertFormReferences(ids[i - 1], $w(‘#bookForm’ + i).value)
insertCharacterReferences(ids[i - 1], $w(‘#bookChar’ + i).value)
insertTimeReferences(ids[i - 1], $w(‘#bookTime’ + i).value)
insertGeoReferences(ids[i - 1], $w(‘#bookGeo’ + i).value)
insertCountryReferences(ids[i - 1], $w(‘#country’ + i).value)
}
} )
. catch ( (err) => {
let errorMsg = err;
} );
}