import wixData from 'wix-data'; import wixLocation from 'wix-location'; $w.onReady(function () { $w("#submitButton").onClick(async () => { let name = $w("#nameInput").value; let comment = $w("#commentInput").value; let image = $w("#imageUpload").value.length > 0 ? await uploadImage() : null; if (name && comment) { let toInsert = { name, comment, image, dateSubmitted: new Date() }; wixData.insert("Reports", toInsert) .then(() => { $w("#nameInput").value = ""; $w("#commentInput").value = ""; $w("#imageUpload").reset(); wixLocation.to(wixLocation.url); // Refresh page }) .catch(err => console.error("Error saving data:", err)); } else { console.warn("Please fill out all required fields."); } }); function uploadImage() { return $w("#imageUpload").uploadFiles() .then((uploadedFiles) => uploadedFiles[0].fileUrl) .catch(err => console.error("Image upload error:", err)); } });
top of page

Subscribe Form

Thanks for submitting!

6317048018

  • Facebook
  • Instagram

©2023 by Split-second vending. Proudly created with Wix.com

bottom of page