Else If statement for dropdown

Hi. I have some code that i want to work with a dropdown every time I change the dropdown

It seems to skip over the first part of the code even though everything may be true
Im using this code to show and hide an English Video player and an Afrikaans video player. The dropdown values are AR and EN
Heres the code I used:

export function updateLang_click(event) {
 let item = $w("#dynamicDataset").getCurrentItem();
 if ((item.ar) && (lang == "AR")) {
$w("#en").collapse();
$w("#ar").expand();
} else  if ((item.en) && (lang == "EN")) {{
$w("#en").expand();
$w("#ar").collapse();
    }
}
}

Heres the dropdown and button

Please show the database, which is related to your issue.

  • please let us see the lang deceleration.
  • Use strict mode: === and not ==

Also get rid of the extra {} in the else if block.

From what I can deduce, you want to change the video players based on the language in the drop down. Each drop down has values you can add.

This is the best method for doing what you are attemping to do, but you need to change your videoplayer id as such:

Step 1: Change Video Player names in this fashion:
name your English videoplayer “#enplayer” and your Afrikaans video player “arplayer”, and all your other video players in such manner.

Step 2: Go to your dropdown and add an “onChange()” function.

Step 3: Add this code to your onChange() function.

export function languagedropdown_change(event) {
    //Hide all of your video players: 
    $w("#enplayer").hide(); 
    $w("#arplayer").hide(); 
    //.... repeat this for all video players. 
    //Gets the Language from the Drop Down List. 
    let language = $w("#languagedropdown").value; 
    //Creates an id for the language chosen. 
    let showplayer = "#" + language + "player"; 
    $w(showplayer).show(); 

}

IMPORTANT: This code assumes your drop down box is called “#languagedropdown”, and the values of the drop down list are the abbreviation of the language: (ex: en, ar…etc).

@josephchancewatkins it works great! thank you so much for the help.

@david12252006 No problem. This method allows you to add more languages indefinitely and all u gotta do is keep the language abbreviation in the IDs. :slight_smile: