Hi,
I'm getting a "script error" while trying to enter data into a dataset using a simple form.
I'm using two radio buttons and a submit button.
This is not a permissions problem. Even when I set writing permissions to "anyone" (and not just members) I get the same error. It is of course set to "read&write".
This is the page's code:
import wixLocation from 'wix-location'; import wixData from 'wix-data'; import { local } from 'wix-storage'; $w.onReady(() => { $w("#marks").onReady(() => { let stage = $w('#marks').getTotalCount() + 1; console.log("current essay to mark: " + stage); $w("#essays").onReady(() => { $w('#essays').setFilter(wixData.filter()); let key = local.getItem("key"); $w("#essays").setFilter(wixData.filter() .eq("nusach", key) .eq("essay", stage) ) .then(() => { console.log("Dataset is now filtered"); let count = $w('#essays').getTotalCount() console.log("Number of essays: " + count); if (stage > 10) { //change here for more than 10 essays $w("#content").disable(); $w("#language").disable(); $w('#submit').disable(); console.log("Elements now disabled") $w("#submit").hide(); //change here let url = "/end"; console.log(url); wixLocation.to(url); } }); }); }); }); and this is what happens when I try to enter data. Everything gets disabled and I get a "script error" message.
Thanks!
All of these scripts can actually be done thanks to artificial intelligence without spending time on development. If you want to learn about it in detail, I recommend you click here caktus ai reviews . The system of artificial intelligence based services that writes scripts works on the basis of a huge database and various sources that allow you to provide you with meaningful and reasoned scripts. You no longer need to spend time researching and gathering information as there are services that can do it for you.
I think that soon these scripts can be done with AI.
Hey! Don't let essay writing hold you back - our service can help you find the right solution. We understand that essay writing can be a difficult and time-consuming process, but it doesn't have to be. With the help of our service, you can find a reliable essay writing service that will take care of the hard work for you. Team of experts from https://essaysrescue.com/extraessay-review/ is dedicated to providing you with the best possible experience and helping you achieve your academic goals.
I managed to solve the problem. This is INDEED a mode issue. For some reason, when the database is set to read&write, the automatic "submit" modifies the first item instead of creating a new one.
I fixed this by manually submitting the entries using "wixData.insert".
export function submit_click(event) { let stage = $w('#marks').getTotalCount() + 1; let user = wixUsers.currentUser; let userId = user.id; let toInsert = { "essay": stage, "_id": userId + "_essay_" + stage, "content": $w("#content").value, "language": $w("#language").value }; wixData.insert("MemberMarks", toInsert) .then((results) => { let item = results; console.log(item) }) .catch((err) => { let errorMsg = err; }); console.log("item submitted"); $w("#marks").save() .then(() => { $w("#marks").refresh(); $w("#content").disable(); //change here $w("#language").disable(); //change here $w('#submit').disable(); //change here console.log("Elements now disabled") }); let url = "/viewing"; console.log(url); wixLocation.to(url); }
Hi,
Maybe try putting a ";" after this line of code: let count = $w('#essays').getTotalCount()
Best,
Nick
https://www.wix.com/code/home/forum/community-discussion/getting-script-error-on-database-save
https://support.wix.com/en/article/wix-code-testing-and-debugging-your-code
Although if it just a simple form, then why not just set it as write only or as members-only form submission
https://support.wix.com/en/article/about-collection-permissions#roles
https://support.wix.com/en/article/setting-permissions-for-your-database-collection