|
Non selectable drop down options in forms |
I was recently developing an application that had several select fields in a form. The first dynamically populated the second, but with differing sets of data, that needed to be within the same select box, but seperated in some way.
It was only then that I found there is a 'optgroup' html tag for select boxes! This tag is used to group together related options in a select list. It automatically bolds the text, and is unselectable.
2<cfset variables.mySecondlist = "5,6,7,8">
3
4<cfoutput>
5<select name="number">
6<cfloop list="#variables.mylist#" index="I">
7 <option value="#I#">#I#</option>
8</cfloop>
9
10<optgroup label="Second List"></optgroup>
11
12<cfloop list="#variables.mySecondlist#" index="I">
13 <option value="#I#">#I#</option>
14</cfloop>
15
16</select>
17
18</cfoutput>
Just insert it where you want your category break to be, and assign it some text.
Handy for breaking up large sections of options.
There are no comments for this entry.
[Add Comment] [Subscribe to Comments]