# Input Hide and Show on Drop Down Selection

**URL:** <https://forum.wixstudio.com/t/input-hide-and-show-on-drop-down-selection/27379>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [July 20, 2020, 7:26pm UTC](https://forum.wixstudio.com/t/input-hide-and-show-on-drop-down-selection/27379 "2020-07-20T19:26:48Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![bensmitth](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/bensmitth/32/18743_2.png) [@bensmitth](https://forum.wixstudio.com/u/bensmitth)\
**Post date:** [July 20, 2020, 7:26pm UTC](https://forum.wixstudio.com/t/input-hide-and-show-on-drop-down-selection/27379/1 "2020-07-20T19:26:48Z")

</div>

Hello Everyone,

I simply what a drop downs selection to hide or show an input field. My code almost works, for some reason if i select either of the two drop selections it will hide the input field, and also wont show it if I change the selection . Any help would be greatly appreciated.

export function dropdown3\_change() {  
**if** ($w( “#dropdown3” ).value === 1 ){  
$w( “#input1” ).show();  
} **else** ($w( “#dropdown3” ).value === 0 )  
$w( “#input1” ).hide();  
}

Thank you!

---

<div class="post-metadata">

**Author:** ![tony-brunsman](https://avatars.discourse-cdn.com/v4/letter/t/ea5d25/32.png) [@tony-brunsman](https://forum.wixstudio.com/u/tony-brunsman)\
**Post date:** [July 20, 2020, 10:41pm UTC](https://forum.wixstudio.com/t/input-hide-and-show-on-drop-down-selection/27379/2 "2020-07-20T22:41:56Z")

</div>

Hi Ben,

The seemingly numeric value of the dropdown is actually of the type text. Put quotations around the “1” and “0”.

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [July 21, 2020, 5:04am UTC](https://forum.wixstudio.com/t/input-hide-and-show-on-drop-down-selection/27379/3 "2020-07-21T05:04:00Z")

</div>

Hello together,

in addition to Anthonys advice (which wants you to convert the type of your values) , i can give you another (not very correct, but working way) to solve your problem.

I call it —\> “the lazy way” 😁

This is your code, try again… (normaly this should also work).

```javascript
exportfunction dropdown3_change() {if ($w("#dropdown3").value == 1){ $w("#input1").show(); } else ($w("#dropdown3").value ==0) $w("#input1").hide(); }

```

But it is not tested, and is also not the very correct way.😁

---

<div class="post-metadata">

**Author:** ![anon72313111](https://avatars.discourse-cdn.com/v4/letter/a/94ad74/32.png) [@anon72313111](https://forum.wixstudio.com/u/anon72313111)\
**Post date:** [July 21, 2020, 5:38am UTC](https://forum.wixstudio.com/t/input-hide-and-show-on-drop-down-selection/27379/4 "2020-07-21T05:38:35Z")

</div>

Hi Ben 🖐

You can use either the [**value**](https://www.wix.com/corvid/new-reference/$w/dropdown/value) or the [**selected index**](https://www.wix.com/corvid/new-reference/$w/dropdown/selectedindex) properties to check whether to show or hide the input field.

```javascript
let value = $w("#dropdown3").value;
let selectedIndex = $w("#dropdown3").value.selectedIndex;

// Using the value property
if (value === 'Empty') {
    $w("#input1").hide()
} else {
    $w("#input1").show()
}

// Using the selected index property
if (selectedIndex === 0) {
    $w("#input1").hide()
} else {
    $w("#input1").show()
}

```

Hope this helps~!  
Ahmad

---

<div class="post-metadata">

**Author:** ![bensmitth](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/bensmitth/32/18743_2.png) [@bensmitth](https://forum.wixstudio.com/u/bensmitth)\
**Post date:** [July 21, 2020, 3:45pm UTC](https://forum.wixstudio.com/t/input-hide-and-show-on-drop-down-selection/27379/5 "2020-07-21T15:45:47Z")

</div>

Thank you for all of your replies. But unfortunately I am still experiencing the same problem with each solution you have all suggested. For each suggestion if I select either selection from the drop down the input field will disappear and not reappear if i select either selection.

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [July 21, 2020, 4:10pm UTC](https://forum.wixstudio.com/t/input-hide-and-show-on-drop-down-selection/27379/6 "2020-07-21T16:10:21Z")

</div>

Whaaaaaaaaat? 2x Corvid-Masters and a Ninja could not help you? 😁

DAMN! Ok, perhaps this can help you…

[https://russian-dima.wixsite.com/meinewebsite/enable-button-check](https://russian-dima.wixsite.com/meinewebsite/enable-button-check)

It’s an absolut similar example to your issue.

EDIT:  
And Ahmand’s solution should also work, there was just a little COPY & PASTE misstake…

```javascript
let value = $w("#dropdown3").value;
let selectedIndex = $w("#dropdown3").selectedIndex;

// Using the value property
if (value === 'Empty') {
    $w("#input1").hide()
} else {
    $w("#input1").show()
}

// Using the selected index property
if (selectedIndex === 0) {
    $w("#input1").hide()
} else {
    $w("#input1").show()
}

```

So you have more then 2 different ways how to do it 😉

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [July 21, 2020, 4:26pm UTC](https://forum.wixstudio.com/t/input-hide-and-show-on-drop-down-selection/27379/7 "2020-07-21T16:26:48Z")

</div>

Create a new page.

1. Create a INPUT + DROPDOWN (“input1” + “dropdown1”+)
2. Insert teh following code for example into your page-code-section (just COPY & PASTE).
3. Modify the given CODE by your needs if needed.

```javascript
$w.onReady(function () { });

export function dropdown1_change(event) {xxx()}

function xxx (parameter) {
 
 let value = $w("#dropdown1").value;
 let selectedIndex = $w("#dropdown1").selectedIndex;

 // Using the value property
 if (value === 'Empty') {
        $w("#input1").hide()
    } else {
        $w("#input1").show()
    }

 // Using the selected index property
 if (selectedIndex === 0) {
        $w("#input1").hide()
    } else {
        $w("#input1").show()
    }
}

```

and here a special-example just 4 you…  
[https://russian-dima.wixsite.com/meinewebsite/bounty](https://russian-dima.wixsite.com/meinewebsite/bounty)

As you can see, it is Ahmads suggested CODE but a little bit more expanded.

With this CODE you can work with both methods (value & selectedIndex).

---

<div class="post-metadata">

**Author:** ![bensmitth](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/bensmitth/32/18743_2.png) [@bensmitth](https://forum.wixstudio.com/u/bensmitth)\
**Post date:** [July 21, 2020, 4:54pm UTC](https://forum.wixstudio.com/t/input-hide-and-show-on-drop-down-selection/27379/8 "2020-07-21T16:54:51Z")

</div>

I finally got it working! I am new to Corvid as you can tell. Thank you so much for your help and patience!

---

<div class="post-metadata">

**Author:** ![CODE-NINJA](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/code-ninja/32/110588_2.png) [@CODE-NINJA](https://forum.wixstudio.com/u/CODE-NINJA)\
**Post date:** [July 21, 2020, 5:03pm UTC](https://forum.wixstudio.com/t/input-hide-and-show-on-drop-down-selection/27379/9 "2020-07-21T17:03:35Z")

</div>

No problem! We all started at ground ZERO 😆
