Nothing
Nothing

Reputation: 2642

How to make multiple select output, the same with the single select

I have html like this:

<select name="sortProducts" id="sortProduct" multiple="multiple">

<optgroup label="Availability">
    <option selected="selected" value="option1">Low to high</option>
    <option value="option2">High to low</option>
</optgroup>

<optgroup label="Price">
    <option value="option3">Low to high</option>
    <option value="option4">High to low</option>
</optgroup>

</select>

When I used multiple="multiple", It shows all of my element in combo box, so how can I hide it to show only the first choice like the single combo box? Anyone have some idea about that? Thanks.

Upvotes: 0

Views: 147

Answers (1)

Ayman Safadi
Ayman Safadi

Reputation: 11552

Remove the "multiple" attribute.

It looks like you need to separate the 2 categories though.

<select name="sortProductsByAvailability" id="sortProductsByAvailability">
    <option selected="selected" value="option1">Low to high</option>
    <option value="option2">High to low</option>
</select>

<select name="sortProductsByPrice" id="sortProductsByPrice">
    <option selected="selected" value="option3">Low to high</option>
    <option value="option4">High to low</option>
</select>

Upvotes: 1

Related Questions