"Next State" command for Multistate Box

Hello, I have my multistate box coded where it’s controlled by a drop down menu. I would like to add a back / forward button at the top that is static and is coded to move back or forward states when clicked.

    $w('#selectcourse').onChange(() => {
 if ($w('#selectcourse').value === "01") {

Any help is greatly appreciated! Thank you.

This is a code-part of one of my sites, where i have exact your wished functionality…

var counter = 1

$w.onReady(function () {
        let currentState = ("State"+counter)
        if(counter>1) {$w('#btnPrevious').show()}

        let currentState = ("State"+counter)
        if(counter===1) {$w('#btnPrevious').hide()}

Modify this code to your own needs😉
“btn” —> BUTTON
“MSB” —> MultiStateBox

You will have to make it perfect, because this code is not complete.

How is not complete? I’ve very new to Velo.

I tried this and it didn’t work. I also tried to do export function buton_click(event) with those commands and resulted in nothing as well.

What am I missing?

Thank you!

I will reply later… to be continued…

Ok, here i am again!

To use this CODE, you will need to have the following elements in your project…

  1. Multi-State-Box (MSB —> ‘#MSB1’ )
  2. 2x-Buttons → Previous + Next ( ‘#btnPrevious’, ‘#btnNext’ )
  3. And of course you should have more than 1-State in your MSB !

That’s it! :wink:

The shown CODE is doing his job on this site…

P.S.: You do not have to connect any button. Everything is already done by the shown code. And one more thing! This code, is not 100% complete and has to be modified. You will understand what i mean, when you will use it :wink: