Help with dropdown

Guys, I need your help … I need to when a person clicks a dropdown option, expand a box with information for that option that they selected in the dropdown. can you help me?

Select the dropdown and go to Properties panel on the right of your screen. Select the event click and hit enter. Something like this will come up in the code editor.

$w("#dropdownID").onClick( (event, $w) => { 
 // The dropdown has been clicked
} );

Then add a box to your page with the information inside you want. Select it, go to properties panel and make it collapsed by default.

Then add the below code into your above click event like this

$w("#dropdownID").onClick( (event, $w) => { 
    // The dropdown has been clicked 
    $w("#myBOXElement").expand();
} );

Then the box will expand and show the info inside.

2 Likes

That’s right! But what I am not getting is the following.
My DropDown has two options. For example: GREEN AND YELLOW, when the person selecting green appears the green box, and when selecting yellow the yellow box appears. I’ll put an example print.

follows the example, I need that when someone selects a color in the dropdown appears only the box referring to that color.

?

Hi,
You can simply use an if statement, for example:

$w("#dropdownID").onClick( (event, $w) => { 
    // The dropdown has been clicked 
    if($w("#dropdownID").value === "yellow"){
          $w("#myGreenBox").collapse();
    }
    else{
          $w("#myYellowBox").collapse();
    }
} );

Good luck :slight_smile: