02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoNext Video

Grouping Combo Elements with optgroup

When your combo list is really long you might want to group it into smaller subsections to do that we will use the optgroup.

Video Transcript

00:00Welcome back. So in the last video we talked about the select and the option we saw how to create a drop-down box
00:05Now in between I added 10 real kind of values such as super grade all the way to me sucking or a sucking or
00:13Something sucks. You know, that's not nice
00:16All right, so I'm gonna comment down that size thing because I don't want it there. I want to have like a regular
00:21Traditional combo box. I'm just gonna put it there in a comment right below. So you could remember how to use it
00:27And I want to start talking about a new property now the new tag enables us to cluster options together
00:33So for example, in our case when we have here all these super options
00:36We might want to cluster them together into one group of items to do that
00:41I'm basically just gonna type option group and that's gonna be my tags
00:45Let me just put that inside of a tag option group and I'm gonna define. Oh
00:51That was painful
00:53You're okay. Yeah, okay, and I'm gonna group everything that's super inside of the super group. All right, that makes sense
01:00Yeah
01:01And all that really did is and I'm gonna create another option group and we're gonna put a group for this one and a group
01:06For that one, although we didn't have to and you can have multiple levels of groups. Okay, oops
01:12Let me just make sure that I'm making it correctly. So I have your one group and here's another group
01:18Let's talk about properties even before we see it
01:20So I want to give it a label give a name to this a group of elements to do that
01:24I'm just gonna put your label and by the way, this isn't something that's selectable
01:27The group itself is not saying that clickable really or you're not sending the group
01:31But it's enabling you to see it in the more easy way for the user
01:36So the label for our super group will be the super
01:41Super group and the label for our regular group will be original as well
01:47Regular
01:50All right
01:52Once we've created these two groups are ready to see how they work. So I'm gonna go right into our
01:58Browser click on refresh and this time around I want to open up my element. You'll see that we have a grouping
02:04So basically you'll see a title and some options a title and some options as you were saying earlier when you're for example
02:09Selecting a country and a drop-down list. Sometimes you'll see in those drop-down lists such as
02:14Asia and then underneath it all the countries
02:17America and all the countries in America and so on and so forth. So it's really just for organizational levels, but it's not really clickable
02:24All right

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!