0

I am looking for a HTML "select" which can display in groups.

Chosen -- http://harvesthq.github.io/chosen/ can do this but only one level of grouping

I am looking of nested groupings

ex:

Product
   SW
     C1
     C2
   HW
   Infrastrcture
     S1
     S2
Dipen Shah
  • 1,883
  • 10
  • 29
  • 44
KK99
  • 1,911
  • 7
  • 31
  • 60

2 Answers2

0

You can always indent the options text like below to get the desired output

<select>
    <option>Product</option>
    <option>&nbsp;SW</option>
    <option>&nbsp;&nbsp;C1</option>
    <option>&nbsp;&nbsp;C2</option>
    <option>&nbsp;HW</option>
    <option>&nbsp;Infrastrcture</option>
    <option>&nbsp;&nbsp;S1</option>
    <option>&nbsp;&nbsp;S2</option>
</select>

Check here how it looks like.

kiranvj
  • 27,729
  • 5
  • 65
  • 72
-1

I believe what you are looking for is something like this:

Here is the code of the reference site:

<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>
Mike Angel
  • 51
  • 8
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. – Dipen Shah Aug 12 '15 at 20:38
  • Indeed I will update the answer, thanks for the tip! – Mike Angel Aug 12 '15 at 20:39
  • Thanks. I am looking for more than 1 group. Optgroup supports only one level of grouping I believe – KK99 Aug 12 '15 at 20:47
  • That is correct it supports one group. Anyway you can use ` ` to add the desired space, disable attribute so the option cannot be selected and some `CSS` to give a the disabled option a white background and make the text bold. Example: `` – Mike Angel Aug 12 '15 at 20:57