Help.... Using dropdown element to load a page

Hello all,
I will start off with thanking everyone for the abundance of examples and information on using WixCode. I am brand new to coding.
I have done a good amount of searching and can’t find information on what I am trying to accomplish. Basically I want to have a userinput dropdown element that has multiple categories already listed. Once the user selects one of these categories and clicks the submit button it loads a specific page based off of the category they chose.

Any help would be greatly appreciated. If there happens to be another post answering this, I apologize, I didn’t find it.

Thank you!

You can use the onClick() event handle function to find which option was selected, and then use wixLocation.to() to jump to the page you want. Something like this:

import wixLocation from 'wix-location';
...
export function selection1_click(event, $w) {
let dropdownSelIndex = $w("#selection1").selectedIndex; 
    console.log(dropdownSelIndex);
    if(dropdownSelIndex === 1) {
        wixLocation.to("/page1");
    }
    else if(dropdownSelIndex === 1) {
        wixLocation.to("/page2");
    }
}

I hope this helps,

Yisrael

1 Like

Thank you Yisrael! You are awesome… that worked great!