Hi,
You should check if it’s the last slide of the slider, and if so - set the value to the relevant element. It should be something similar to this:
import {session} from 'wix-storage';
let numberOfSlides;
$w.onReady(() => {
// Set the global numberOfSlides variable from the slideshow length.
numberOfSlides = $w('#quizSlides').slides.length;
});
export function slides_change(event, $w) {
if (isLastSlide()) {
let productid = session.getItem('productid');
$w('#buttonId').text = productid;
}
}
function isLastSlide(){
// Check if the current slide is the last slide.
return $w('#quizSlides').currentIndex === numberOfSlides - 1;
}
Moreover, I recommend checking out our Gift Quiz example, which has a similar scenario.
Good luck,
Tal.