January 17, 2002

Intersting Grouping Option for Select Fields

Display Title for Fieldset

(I tried using the extended characters to show the code here, but Graymatter is converting it automatically, which is annoying. So look at the code.)

This shows the ideal section of a select field in a form. The intersting thing here that isn’t really used much (at all? Ever?) is the Optgroup. I know that NS doesn’t display this at all. But it ignores it nicely, which is something at least. IE displays this nicely.

Your dropdown will look something like the following:

Title for Grouping 1

Option 1

Option 2

Title for Grouping 2

Option 3

Option 4

Nice, eh?

What it does is take your insanely long or convoluted select boxes, and groups them according to the hierachies you define. HTML 4.0 DOES NOT allow nesting of the optgroup. To quote the W3C HTML 4.0 Spec:

“Implementors are advised that future versions of HTML may extend the grouping

mechanism to allow for nested groups (i.e., OPTGROUP elements may nest) as

shown in the above example. This will allow authors to represent a richer

hierarchy of choices.”

The other stuff, labels, fieldsets, legends are common field items that should be used more often, as they are a great boon accessibility-wise.

Post Info

Tagged As Coding

Comments are Open (0)

Posted at 12:00 PM

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)

Search
Comments on this post
Categories
Info
Tony Stephens
Copyright © 1995-2005
Site Version:
10
Licensed:
Creative Commons
Validate:
XHTML, CSS, 508, RSS
Subscribe
Blog-Fu, Link-Fu