I need to create a button in a product quiz on my website that will collect a one word data entry for the database. There will be 2 buttons, and if they click one, it will send the word “one” to the database vs if they click two, it will send the word “two” to the database.
You will need something in this direction…
$w.onReady(function () {
$w("#YourDatasetIDhere").onReady( () => {
$item("#YourButtonIDhere").onClick((event) => {
//YOUR CODE HERE....for example....
$w("#YourDatasetIDhere").setFieldValue("title", "New Title");
$w("#YourDatasetIDhere").save();
})
})
})
The field key for where the one/two word answer in the database should be added is “answer” where do I need to input this?
$w("#YourDatasetIDhere").setFieldValue("answer", "RESULTofCHOICE");
Nathan you should first learn some basics, before you start coding.
- How to work with buttons?
- How to work with Databases?
- Learn the syntax, operators ans so on.
You can take a look on my website if you want, there are some very simple examples. Start there first and learn some basic stuff, before you start coding your own projects.
Especialy take a look at the beginner-tutorials, which will show you for example how to work with buttons and other elemnts.
I figured it out by editing the code a bit. I know code enough to have gotten everything up to this point which this is the last step. It is just a lot different using wix code for me than anything else. Anyways, do you think that you could help me with the only thing I have left, which I made a post for on my profile? Thanks!
Sorry, today i am not very motivated. Perhaps tormorrow.
Yeah, i see your motivating attempts