The issue I am having now is how to get the number of likes to stay on screen. The number of likes only gets displayed for 1 second after I click the button, then it disappears.
Another question I have is, if I have multiple like buttons to connect them to the correct row on the database, would I just change this line of code:
let answersitem = result.items;
I would just change the x value to the corresponding row, right?
Mikhail, are you still there? So this codes works such that it increases the like counter field. However I am still stuck on how to get the number to stay on screen.
Doing:
$w(‘#text71’).text = answersitem.likefield.toString();
Displays the number of likes for 1 second, then the number disappears. How do I get this number to stay?
Field names are case-sensitive. In code you used “linkfield”, but from content manager view it looks like your field is named “linkField”. That means that after code is executed, it addes likes to feild “linkfield”
At the same time, on page, your text field (i believe) is connected to text to show number of likes
In code you first assign text element to number of likes which you get from collection (and you see this number) and then refresh dataset, which results in taking variable from current item from database, with field key “linkItem”
hello mikhail,
how can i make a dataset save the random number obtained from this code to a db
export function button1_click(event) { $w(" #text3 ").text = (Math.floor((Math.random() * 20) + 1)).toString(); }
I copy pasted ur code into my website on my button as onClick event and it still doesn’t work. Nothing is being added to the collection at all. Any ideas why?