Enable A Input Text When Selected A Specific Option

so while i was trying to create a website i was trying to know how can i create a code when the human selects a specific option from the dropdown it enables a button i tired alot of things i couldn’t get it to work

Hi Omar :raised_hand_with_fingers_splayed:

You can by capturing the value of the dropdown menu when its value changed using its onChange() event handler to enable or disable an input field.

$w('#dropdown1').onChange( (event) => {
    if ($w('#dropdown1').value === "Other") {
        if (!$w('#input1').enabled) {
            $w('#input1').enable();
        }        
    } else {
        if ($w('#input1').enabled) {
            $w('#input1').disable();
        }
    }
})

If you have any further questions please feel free to ask.

Hope this helps~!
Ahmad

well i knew a little how to deal with the values but it still dosen’t do anything the input text is still not getting enabled

Maybe you’re not implementing the code in the right way, paste the code here in a code block and give us the site URL in order to to be able to help you better.

Hello Omar,
pehaps you are searching for something like this? Take a look…

https://russian-dima.wixsite.com/meinewebsite/enable-button-check

export function dropdown1_change(event) {console.log($w('#dropdown1').value)
    if ($w('#dropdown1').value==1) {$w('#BTNstart').enable()}
    else {$w('#BTNstart').disable()}
}

Omar, you need to set the input field to be disabled on load, right click on the input field, click " View Properties ", a panel will open and make sure " Enabled on load " is not checked, then use my code.

russian-dima, he’s trying to check the value of the dropdown menu, not the index, it’s different.

ok, i just overflew this post…

so while i was trying to create a website i was trying to know how can i create a code when the human selects a specific option from the dropdown it enables a button i tired alot of things i couldn’t get it to work
was not clear for me, but ok. Like i always say, there are many ways to Rome :grin:

Indeed, all the ways lead to Rome :grin:

@ahmadnasriya Hi Ahmed,
Could you please let me know if this code can work inside repeater?