form enable disable button NOT WORKING

hi this is my code but it is not working. a radio button question should be answered first before the drop-down is enabled

$w.onReady( function () {
$w (“#dropdown1”).disable();
//TODO: write your page related code here…

});

export function radioGroup2_change(event,$w){

let selectedIndex = $w(“#radioGroup2”).selectedIndex;
$w(“#radioGroup2”).selectedIndex = 0;

if (selectedIndex>=1){
$w(“#dropdown1”).disable();

}  **else** { 

$w("#dropdown1").enable(); 

} 

}

Please note, that you don’t have to disable the dropdown by setting it as disabled in an onReady function. Instead, you can choose it to be disabled by default in the properties panel of the element.

In addition, the if statement that you have doesn’t need to be compared to a number of a selectedIndex. When the radio button is not selected, its selectedIndex equals undefined . I recommend you to to compare the selectedIndex variable to undefined (radio button is not selected) and enable the dropdown if it’s not the case.

You will get something similar to this:

export function radioGroup_change(event) {
let selectedIndex = $w(“#radioGroup”).selectedIndex;
if (selectedIndex !== undefined) {
$w(“#dropdown1”).enable();
}
}