hide and show inputs depending of the dropdown selection

i have a dropdown i want to show an input or hide it depending of the selection of dropdown please help me with full code

1 Like

Hi Ravand,

Here is a site that I created that has the functionality you are wanting: https://muniturbusiness.wixsite.com/mysite-19
If user selects any other category than “Legal” in the dropdown, they will see formA. If user selects “Legal”, they will see formB.

I can’t give you the full code you need but I can give you a starter. You should be able to adopt it to fit your needs.

import wixData from 'wix-data';
export function myDropDown_change(event) {
 
 if($w("#myDropDown").value === 'Legal') { //replace 'legal'
        $w("#myInput").show();
      } else {
        $w("#myInput").hide();  
      }
}
 

thanks for you bro i did it

I have same question.

my code is:

import wixData from 'wix-data';
export function myDropDown_change(event) {
 
 if($w("#dropdown1").value === '紹介') { //replace 'legal'
        $w("#input1").show();
      } else {
        $w("#input1").hide();  
      }
}

It’s not working.
it’s in the lightbox, is there anything else I need to do?

yes change this name(myDropDown) on your code to (dropdown1) it will work because u should write the same name in both places

I already try it. but not working.

import wixData from 'wix-data';
export function dropdown1_change(event) {
 
 if($w("#dropdown1").value === '紹介') { //replace 'legal'
        $w("#input1").show();
      } else {
        $w("#input1").hide();  
      }
}

The spelling is also correct.

@nanami you have to do another step remove all ur code select the dropdown and click the onChange tab in the right then click on the page code it will automatically write this code (export function dropdown1_change(event) {} ) then type the code you want on the brackets {}

@ravand0010
Thank you so much!!!
It’s solved!!!
I forgot to check there…

you are great!!!

@nanami you are welcome brođź’š

how did you solve it?

Sorry this was so long time ago.
So i forgot…

Please open your own post with your own in detail described issue.
And someone will surely take a look onto your problem.