Linking url's to dropdown menu options

Hi! I’m trying to link the dropdown menu options to different pages on my wixsite. The problem I encounter is that it only goes to the pages after the second time I change an option.

For example: the values in the dropdown are:

  • “French”
  • “English”
  • “German”

(All three are linked to a different wix page.)

whenever I change to for example: “English” , nothing happens…
When I then change to “french”, “English” opens…

It looks like it only works on the second click. Here is the code that I used. Does anybody know what is going wrong here? Thanks a lot!

export function dropdownLanguage_change(event) {
//Add your code for this event here:
let filterLanguage = $w(‘#dropdownLanguage’).value;

$w('#dropdownLanguage').onChange(() => { 

if (filterLanguage === ‘frances’) {
wixLocation.to(“/frances”);
}
if (filterLanguage === ‘aleman’) {
wixLocation.to(“/Aleman”);
}
if (filterLanguage === ‘espanol’) {
wixLocation.to(“/Espanol”);
}
if (filterLanguage === ‘ingles’) {
wixLocation.to(“/Ingles”);
}
if (filterLanguage === ‘otrosidiomas’){

        wixLocation.to("/OtrosIdiomas"); 
    }} 
    ); 
}

So what is the first label in the dropdown? Do you have one and do the values of the dropdown correspond to the correct statements in the IF. You do not show the values in your dropdown.

Hi Andreas, Thanks for your answer. Here are the values I set for the dropdown. Does it have to be in order?

Ah you have two dropdown events inside each other, take away the inner one

@andreas-kviby Thanks!! Now it works perfectly.

@profyco great! Please mark it as top comment as it helps me

Hi Folks,
I’m not a wiz at code and would love some guidance on how to add a button to my Wix page that has a drop down menu with links to other pages on my wix site.

Any and all advice most gratefully received!

:slight_smile:

To learn about programming with Velo, read the following articles that will help you start working with Velo:

This is an old post and is being closed.