I’ve been trying to create a button that simulates a form submit button but can add things to the dataset outside of the form.
My Idea was that " onClick() " I could use the " setFieldValues() " command to add data to the dataset, then use the " save() " command to save it. The final part was then to go to my homepage.
The code I came up with is below:
$w('#button2').onClick(function () {
$w('#dataset1').setFieldValues({
"name": $w('#input3').value,
"email": $w('#input2').value,
"phone": $w('#input1').value,
"business": wixLocation.query["name"],
"location": wixLocation.query["loc"],
});
$w('#dataset1').save();
wixLocation.to("/Home");
})
I have linked the button to a dataset that has been labeled “$w(‘#dataset1’)” but I’m not seeing any now data in the dataset.
My gut reaction is that I’m using “setFieldvalues()” wrong but I’ve had a look at the documentation and I can’t see anything I’ve done differently to their second example. I have also tested with line 2 above nested inside a “$w(‘#dataset1’).onReady” command but still no success.
Any ideas thoughts or opinions are more than welcome and thank you for your time.
Edit 1: The dataset is just a default one created by Wix, I haven’t messed about with it other than to look at live data rather than sandbox data.
Edit 2: I’ve checked the dataset and made sure that all of the names of fields match those in my code. Still doesn’t work