Thanks for that.
I’ve spent a few hours working on it and have decided to keep it as 2 separate pages, one for submitting and one for updating.
The only issue I am facing now is the uploading of images using the upload button.
I’m kind of hoping that I can use the let toInsert to insert the image. I’ve read the api documents and a whole ton of forum posts. Once I can figure out how to upload images to the database then I think I’ll have cracked it!
function saveProperties() {
$w('#buttonSubmit').disable()
let uniqueClicks = 0
let toInsert = {
"title": $w("#input2").value,
"agentEmail": $w("#input3").value,
"mapLocation": $w("#input36").value,
"businessWebsite": $w("#input35").value,
"facebook": $w("#input33").value,
"instagramLink": $w("#input34").value,
"hoursOfOperation": $w("#input37").value,
"description": $w("#richTextBox1").value,
"familyPic1": SOMETHING NEEDS TO GO HERE,
"uniqueClick": uniqueClicks,
"_userId": userId
};
wixData.insert("Properties", toInsert)
.then ((results) => {
let item = results;
console.log(item);
$w("#textErr").text = "Your information has been submitted"
$w("#textErr").show().then(() => {
$w("#buttonSubmit").enable()
setTimeout(() => {
$w("#textErr").hide()
wixLocation.to("/update-pics-and-links");
}, 5000
)
})
})
.catch((err) => {
let errorMsg = err;
console.log(errorMsg)
});
}