Hi,
To which slider you were referring? I’m not sure that I fully understand the scenario. Can you please add a screencast of the issue so that we can better understand what you were referring? Simply recreate the issue while recording the steps and add the screencast.com URL to your response.
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.
Thank you for taking your time helping. I used your code and have succeeded adding the productID to my text field located in the last slide. However, when the form is submitted, the value is not submitted into the backend database, (it shows up blank in the table). It is only submitted when the code is inside $w.onReady . which works only (on the first slide when the page is loaded). Not working for the third slide. Any ideas?
Hi,
I don’t know how you’ve inserted the information to the collection. You can use the insert function for that purpose. Should the issue persists, please share with us the code you’ve written.