Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Emma Willmann
Treehouse Project ReviewerConditional Forms
I am wondering how to go about having conditional options in an html form. My quick search online is talking about using javascript. I was wondering if there is a way to do it with only html/css.
Example:
Creating a form for ordering shirts for a work Christmas present. First, you have an option of a t shirt or a polo. Then you have the option of a mens or womens shirt. Finally, each shirt has different sizes depending on if it's mens or womens. So, if I had 3 drop downs, 1 - men/women, 2 - type, 3 - size, I would need the size drop-down to be dependent on the type drop-down.
1 Answer
Jonathan Grieve
Treehouse Moderator 91,254 PointsHTML is a markup language. CSS can detect an element that has particular focus using a pseudo selector but you'd need to use a programming language like Javascript to do get what you're wanting to do I'm afraid.
You might be able to display a different colour based on the value of a HTML dropdown but if I've understood you correctly i think that;s it. :-)
Emma Willmann
Treehouse Project ReviewerEmma Willmann
Treehouse Project ReviewerThanks. That's what I thought, but I figured it didn't hurt to ask.