I have a testimonials slideshow on my webpage, each slide showing a review from a different person. The testimonials are submitted by form to a dataset. I would like to link some slide show elements to display data from the dataset, each slide getting data from a different row (different person). I tried to link elements in the editor using “Connect to data” button, but when I do so every slide gets information from the same row, and as a result is the same. I tried then to come up with a coding solution, but I am very green with JS and have no idea how to do it.
$w.onReady(function () {
// Setting the rating display 1
let index = $w("#Section1Slideshow").currentIndex; // getting current slide index
$w("#dataset2").setCurrentItemIndex(index); // setting the dataset current item id
let currentItem = $w("#dataset2").getCurrentItem(); // getting the current item
let newRating = currentItem.rating; // getting the rating from the dataset
$w("#ratingsDisplay1").rating = newRating; // assigning the rating from the dataset to page display
});
In this short example, I am trying to get customer rating review from the dataset and set it to a rating display element. I would like this to work for every slide, but the problem is that on every slide the rating display has a different id, so I cannot do it generically (like I am trying here), I have to set value to each manually, which is a nuisance. Besides, when I try setting the value manually it doesn’t even work either.
$w("#ratingsDisplay1").rating = 1; // assigning the rating from the dataset to page display
$w("#ratingsDisplay2").rating = 2; // assigning the rating from the dataset to page display
This produces absolutely no reaction on the page.
I would be grateful for any suggestions how to implement what I described. I suppose I would have to make the slide elements belong to the slide somehow, so that their id is child to that of the slide, then I could refer to them generically. And how to properly assign the value of each element, depending on slide number, I do not know…