Wix-Session Storage Data loading to a Slider's 3rd slide.

Hi Guys,
I have a data loaded to wix-storage session.
I have no problem loading the data from the storage, with the code below.

import {session} from ‘wix-storage’;
$w.onReady( function () {
let productid = session.getItem(‘productid’);
$w(‘#productidinput’).value = productid;
});

The problem I am facing is that the data can only be loaded to the first slide on my Slider, but not the third slide where i want it to be.

How can i fix this ?

Thank you in advance.

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.

Thanks,
Tal.

Hi Tal,

Thanks for your reply.
I’ve recorded a video, sorry for the audio volume, it’s kinda low.

Heres the problem im facing. I hope you can help. Thank you in advance.

Anyone ? Need help.
Thanks.

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.

Hi Tal,

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?

Thank you in advance Tal.

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.

Tal.