Hi! Im Jose Luis,
i need to create a button who let me add +1 to a field in the database:
Example (as a like button):
In data base i have a column called “Likes” with 6 rows, each row is a style of meat.
what i want to create is a sort of like button. If a member like it, he has to click to the love button, and this one will send a +1 command to the field of this meat.
If before the like value was 0, now is 1, and for each click add +1, so later the value will change to 2, 3 ,4 ,5 etc… the number of times the button has been clicked.
i tried to use many codes of this forum, but none has worked as I wanted.
import wixLocation from 'wix-location';
$w.onReady(function () {
let clickCounter = 0
$w('#button1').onClick(()=>{
clickCounter=clickCounter++
console.log(clickCounter)
})
});
Take also a look onto the following examples…
https://russian-dima.wixsite.com/meinewebsite/blank-26
and…
https://russian-dima.wixsite.com/meinewebsite/simple-return-function
How to save data, when using DATASETs, you will find an simple example here…
https://russian-dima.wixsite.com/meinewebsite/dublicate-database
And this one is to use without DATASETs…
Thank you very much! i will try to make it work and then i will quote you to tell how it goes.
Thanks a lot!
it works perfectly thanks!
@josesusoyacobi
You are welcome.
Is there any way to stop someone clicking multiple times?
You could create something like an click-timer.
Than a click would be just possible after a specific time.
Take a look here to gather some ideas, how to code it…
https://russian-dima.wixsite.com/meinewebsite/date-time-onclick
Thanks, that’s interesting.