Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Input with datalist grouping

I do with select in two ways:

  1. With disabled option.
  2. With optgroup tag.

<select name="curso1" id="curso1">
    <option disabled="" style="font-size:12px; text-align:left; font-family:Arial Black">Group</option>
    <option value="1">Windows 8</option>
    <option value="8">lalalala</option>
</select>
<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>

How to do this in a datalist?

How do group with the datalist?

like image 480
Eduardo Dallmann Avatar asked Oct 23 '15 20:10

Eduardo Dallmann


1 Answers

This looks neat on Chrome, but I don't know how it will render in other browsers.

enter image description here

<label>Choose a browser from this list:
<input list="browsers" name="myBrowser" /></label>
<datalist id="browsers">
  <option value="Brave">GroupA</option>
  <option value="Firefox"></option>
  <option value="Safari"></option>
  <option value="Opera">GroupB</option>
  <option value="Internet Explorer"></option>
  <option value="Microsoft Edge"></option>
</datalist>
like image 114
rafaelcastrocouto Avatar answered Oct 21 '22 07:10

rafaelcastrocouto