Question:
My input and dropdown data on screen is not submitting into my CMS collection. this works when I ‘preview’ and test it but as soon as I ‘publish’ and try nothing happens.
below is my code:
import wixData from ‘wix-data’;
$w.onReady(function () {
$w('#SubmitSale').onClick((event) => {
var name = $w('#StrainDropdown').value
var amount = $w('#StrainAmount').value
var cash = $w('#StrainCash').value
let toInsert = {
"StrainName": name,
"StrainAmount": Number(amount),
"StrainCashAmount": Number(cash)
}
wixData.insert("Sales", toInsert)
.then((item) => {
console.log(item);
})
.catch((err) =>{
console.log(err);
})
$w('#StrainDropdown').value = "";
$w('#StrainAmount').value = "";
$w('#StrainCash').value = "";
})
});
Product:
[Wix editor]
**What are you trying to achieve: **
On the submit button the data is supposed to save to the CMS collection. this works in preview mode but as soon as I run publish mode and do it nothing is saved into the CMS.