Drop-down to change a button destination

#dropdown #button code #firsttime

Hey guys,
New to this community & Corvid :slight_smile:

I’m trying to make some kind of mini form with drop-down and a button, drop-down that will have few items inside, each item should change the destination of the button according to the specific item. (If I choose Item-1 on drop-down, the button will lead me to URL1, If I choose Item-2 on drop-down, the button will lead me to URL2, etc.)
I’d like to get some help with it :slight_smile:

Thanks in advance,
Ori

let data = [{"value": "a", "link": "/page1"}, {"value": "b", "link": "/page2"}];
$w("#dropdown1").onChange((event) => {
        let selectedVal = $w("#dropdown1").value;
        if(selectedVal  === undefined){
                $w("#button1").disable();
        } else {
                $w("#button1").link = data.find(e => e.value === selectedVal ).link;
        $w("#button1").enable();
        }
})