Trying to send an integer from one page to another.
Different buttons clicked on SENDING PAGE will mean that a different slide is displayed in TARGET PAGE. In the example below we have button81 setting the value as 5.
That integer is then to be used as the slide number for a slideshow.
CODE ON SENDING PAGE:
import wixLocation from ‘wix-location’ ;
import { session } from ‘wix-storage’ ;
export function button81_click ( event ) {
let value = 5
session . setItem ( “slide” , value );
wixLocation . to ( “/solutions” );
}
CODE ON TARGET PAGE:
import { session } from ‘wix-storage’ ;
let slide= ( session . getItem ( “slide” ));
console.log(slide)
$w . onReady ( function () {
$w ( “#slideshow3” ). changeSlide (slide);
});
This is the error message I’m getting
Values in storage are strings. It should be saved like this:
let value = 5 + '';
session.setItem("slide", value);
Then, the value retrieved from storage needs to be converted to an integer:
let slide = Number(session.getItem("slide"));
Thank you Yisrael. That works perfectly.
Is there any way of trigerring this from the user’s click on items in the wix drop down menu? Or do I need to create an entirely new menu from scratch with my own buttons?
What is it exactly that you are trying to do?
If you save the value in storage one page, then when you go to another page (e.g. via the menu), you can retrieve the value from storage and use it on the target page.
The value I want to save will changed based on the option from the drop down menu that the user selects. I have 14 options, each one sends a number between 1 and 14. On the target page a slide is displayed (slide 1 to slide 14) depending on which menu item the user selected from the previous page.
I have achieved this by created a brand new menu from container boxes and buttons and then a separate container box for each drop down menu which is hidden at first and then appears on hover when the user hovers over the main menu item - however, I can only manage to get the text on the button to change colour on hover. I’d like to get it to have a solid line appear above it.
Unless, of course, there is a way of solving my problem using the wix standard nav bar and drop down options. I don’t know how to trigger events in velo from the drop down list.
The menu bar is called #horizontalmenu2.
However, in Velo, I can’t locate the names for the individual options and drop down lists in the nav bar or work out how to add an event if they are clicked.