Photo Contest need (Like Button)

hello, I want to run a photo contest on my site, but I’m not good at corvid and coding.
the essence is this, on each block with a photo of the participant will be posted: Photo, Participant’s name, age, and information about himself. I want to add a “Like” button to each block on the basis of accumulating likes. Found an approximate on the site. but since not earlier said that he is not strong in coding. I ask you for help.

What you should do:
-Add a collection where people can add their foto’s to.
-Add the columns (creator,discription,image,likeNumber,likedBy(array))
-Add a page with a repeater on it.
-add the following elements(image,texfield(for the creator name, paragraph(for thr discription), a button that will be used as like button).
-Add a dataset to the page linked to the collection.
-link the repeater with the dataset and connect the element with the right fields.

  • go to the code panel and on button click retrieve the amounts of likes, also retrieve the likedBy array.
  • check the array if the user already liked it, if he is not in it
  • add 1 to the likeNumber and add the user to the likedBy list.
    Else remove 1 likeNumber and remove him from the likedBy list

The code for this is a bit complicated and i don’t have the time atm, but you can start trying by yourself :slight_smile:

Kind regards,

thanks, I’ll try, it’s just that I’m just getting to know all this. would be grateful for some kind of photo tutorial of course. I think he would help a lot in the future like me :slight_smile:

1 Like

what’s wrong?


If i find the time tomorrow i’ll make one :slight_smile:

1 Like

Can you post the code in text format. Tell what the error is above or below the code.
This way i can better edit where needed.
Now i can’t see the whole code.
Also tell me what elements you have on the page with their ID.

//elements: 1. dynamicDataset; 2. likeButton; 3. likesText (connected to likes field in the dataset)
import wixData from 'wix-data';

export function button1_click(likebutton) {
 // This function was added from the Properties & Events panel. To learn more, visit
 // Add your code for this event here: 

$w.onReady(function () {
    $w("#dynamicDataset").onReady(() => {
 let item = $w("#dynamicDataset").getCurrentItem();
        $w("#likeButton").onClick((event) => {
            $w("#likesText").text = (Number($w("#likesText").text) + 1).toString();
            item.likesUpdate = true;
            wixData.update("photovitory", item).then(() => { $w("#dynamicDataset").refresh();})

error > #likebutton its not valid selector
error > #likestext its not valid selector


Oke so the photo’s aren’t in a repeater right?
Just a dynamic dataset wich has the data from the current photo?

like button
like text
text name
text about

Oke so we do have a repeater.
Thanks for the info.
I’m off to bed now.
Since this is a bit more complicated, the tutorial about this will take a bit longer to make.
Probably done around this time tomorrow.

Kind regards,

Worst case, i’ll make the code and send it to you.
Since i’ve got a busy day tomorrow :slight_smile:

@volkaertskristof I sort of figured out a little with this point, I just don’t understand why I get an error.
The code would be better

Thx for u :>

Thr first problem i sa is the firsy button event, inside you putted the $w.onReady
Thats something that can’t be done.
$w.onReady is always above on the page and can’t be put in a function or event handler

Next take a look here to access elements in a repeater.

@volkaertskristof I’ll try to do it myself, but as a last resort I count on your help, I have a competition on my nose)