Next & Preview Buttons for Multi-State-Box (Velo)

Hi Together,

I need to have a Next and Preview button for a Multi-State_Box.

Connecting the individual states to different buttons is easy but I cant figure out how to do multiply states with only two buttons.

Do someone have the code or the function for this?

Thank you!!

Mind clarifying a bit more as to the flow. For my example here , I have three states. You can have multiple states and then move use the appropriate code to move to the next state.
https://support.wix.com/en/article/editor-x-using-multi-state-boxes#step-2-add-and-design-the-states

HI, Thanks for your reply.

I like to have a slideshow for my hero section und 2 buttons to switch between the states. I saw this video here and he is using the code below to set a timer to change states.

In the comments someone asked him if its possible to get a next and preview button and he said yes.

“You can use any trigger in order to change states.For click you can use the following:$w(‘ #nextButton ’).onClick(() => { ….changeState function……})”

…I don’t get it.

$w.onReady(function () {
    var states = ['state1', 'state2', 'state3'];
    var stateNumber = 0;

    function slideShow() {
        $w('#multiStateBox1').changeState(states[stateNumber]);
        if (stateNumber < states.length - 1) {
            stateNumber++;
        } else {
            stateNumber = 0;
        }
        setTimeout(slideShow, 6000);
    }
    slideShow();
});

@stschuele Gotcha. Yes. It is weird to right it out with the ellipses like … but the function is here :

$w("#myStatebox").changeState("state2");

That will tell the box to change to the relevant state you want. Note that “#myStatebox” is the id for your Multistate box and “state2” in the code above in the example is the state you want to go to so need to change it appropriately. In my test site, mines looks like this:

export function buttonEvenMore_click(event) {
        $w('#multiStateBox1').changeState('state3');
}

That should work with the timer too if it happens before things time elapses.