Questions tagged [optgroup]

The OPTGROUP element defines a group of choices within a SELECT menu.

The OPTGROUP element defines a group of choices within a SELECT menu. OPTGROUP must contain one or more OPTION elements to define the actual choice

Example:

<select>
  <optgroup label="Swedish Cars">
    <option value="volvo">Volvo</option>
    <option value="saab">Saab</option>
  </optgroup>
  <optgroup label="German Cars">
    <option value="mercedes">Mercedes</option>
    <option value="audi">Audi</option>
  </optgroup>
</select> 

sources: http://htmlhelp.com/reference/html40/forms/optgroup.html, http://www.w3schools.com/tags/tag_optgroup.asp

259 questions
91
votes
12 answers

Nesting optgroups in a dropdownlist/select

I have created a customer c# DropDownList control that can render out it's contents are optgroups (Not from scratch, I edited some code found on the internet, although I do understand exactly what it's doing), and it works fine. However, I have now…
Ed James
  • 10,385
  • 16
  • 71
  • 103
29
votes
1 answer

How to hide optgroup/option elements?

Is there a way to hide option or optgroup HTML elements? I've tried calling hide() in jQuery, and also using regular Javascript to set style.display='none'. It works in Firefox but not in any other browsers. Actually removing them from the DOM does…
DisgruntledGoat
  • 70,219
  • 68
  • 205
  • 290
20
votes
2 answers

Select with optgroup in Symfony 2.0

In Symfony2, the select html component is rendered as a ChoiceType object, which is used indeed also for checkboxes and radiobuttons. Does someone really know how to render a select with the optgroup option in Symfony2? For sake of completeness,…
JeanValjean
  • 17,172
  • 23
  • 113
  • 157
16
votes
2 answers

Adding optgroups in angularjs is proving tricky

I'm using angularjs, and I've been trying to create an optgroup for the past 2 days while working on some other stuff, and I'm stumped. I had to create an ng-options, but didn't consider an optgroup until I realized I needed one. I tried using the…
user54600
  • 268
  • 1
  • 3
  • 11
14
votes
4 answers

How to indent multiple levels of select optgroup with CSS?

Just trying to indent optgroup blocks by nesting depth really, I've tried a general margin-left rule, nested elements then trying to apply the same rule, tried padding-left... is indenting like this possible? It seems elementary :P In the example…
danjah
  • 2,939
  • 2
  • 30
  • 47
14
votes
4 answers

Display result matching optgroup using select2

I'm using select2 with Bootstrap 3. Now I would like to know whether it is possible to display all optgroup items if the search matches the optgroup name while still being able to search for items as well. If this is possible, how can I do it?
Nirmi
  • 1,099
  • 1
  • 8
  • 20
12
votes
3 answers

How to get the optgroup for a multiselect in jQuery?

I am using a multiselect with options grouped together.
kamieduard
  • 133
  • 2
  • 2
  • 6
10
votes
3 answers

Jquery – Select optgroup in select

I have a select with 2 optgroups. Is there a way to call an function only if an option from the first optgroup is selected and call another function if an option from the second optgroup is selected?
user495915
  • 189
  • 1
  • 1
  • 11
10
votes
4 answers

What is the Swing-equivalent to HTML

I want my JComboBox to group multiple options together, similar to the HTML optgroup: I could not find any solution for this in Swing. Manipulating the…
Zak_Rhol
  • 285
  • 3
  • 8
10
votes
2 answers

Creating an optgroup Using simple_form gem on Rails 3.2

There seems to be just a little documentation on the grouped_select feature in simple_form 2.0 at http://simple-form.plataformatec.com.br/#usage/collections. The documentation offers the line: f.input :country_id, :collection => @continents, :as =>…
Tim Knight
  • 8,346
  • 4
  • 33
  • 32
9
votes
4 answers

ASP.Net MVC 3: optgroup support in Html.DropDownListFor

How can i make my DropDownListFor support optgroup? Is there anyway to do it? Notice that this is DropDownListFor, means that it support DataAnnotation client validation
Hieu Nguyen Trung
  • 1,624
  • 5
  • 21
  • 32
1
2 3
17 18