I have a multidimensional array with this structure:
[
{
id: "2",
optgroup: "Size Type A",
valor: "40"
},
{
id: "1",
optgroup: "Size Type B",
valor: "L"
},
{
id: "3",
optgroup: "Size Type B",
valor: "XL"
},
{
id: "4",
optgroup: "Size Type A",
valor: "41"
}
]
My challenge is to create a select list with optgroup using "optgroud" key to arrange items in order.
Like this:
<select>
<optgroup label="Size Type A">
<option>40</option>
<option>41</option>
</optgroup>
<optgroup label="Size Type B">
<option>L</option>
<option>XL</option>
</optgroup>
</select>
But I can't find a way to do this. Any idea! Thanks a lot.