Change code on dropdown lists

Hi all,

Just a quick one, please forgive my lack of code knowledge, I am a real beginner.

I have a dropdown list with 3 items on it. I want to show and hide certain groups of texts depending on what selection is made in the dropdown list. This is the code I have at the moment:
export function dropdown1_change(event) {
// ‘British Airways’
$w(‘#group1’).show()
$w(‘#group2’).hide()
$w(‘#group3’).hide()
}
I guessed adding the line underneath
// ‘easyJet’
$w(‘#group1’).hide()
$w(‘#group2’).show()
$w(‘#group3’).hide()
would hide the first group and show the second group but I can’t get it to work.

Any suggestions would be greatly appreciated. Cheers,
James

Hi James,

The first one would go like this, presuming that the dropdown value is tied to the airline:

if ($w(“#dropdown1”).value === ‘British Airways’){
$w(’ #group1 ‘).show()
$w(’ #group2 ‘).hide()
$w(’ #group3 ').hide()
}

Hi Antony,

Really appreciate such a quick answer. Yep that worked well and I added an else.
Thanks again,
James