Skip to content
Advertisement

Hide or show input on dropdown selection

I am trying to create a sign-up page for my app. All the code works, but when I try to hide input box based on dropdown select, it doesn’t work. I tried this:

JavaScript

But it didn’t work.

And this is my code for the signup page:

JavaScript

Advertisement

Answer

It does work, you only need to place the script underneath the form tags. It can’t execute the script on elements that it can’t find, because they are underneath it. Keep in mind that scripts get executed from top to bottom. I also added selected to the Yes value so when you click No the script starts working.

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement