2011-12-15 73 views
0

我有HTML這樣的:如何使多個選擇輸出,與單相同選擇

<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> 

當我使用多個=「多」,這說明我的所有元素的組合框,因此如何我可以隱藏它,只顯示第一個選擇,如單個組合框? 任何人都有這個想法?謝謝。

回答

1

刪除「多個」屬性。

看起來你需要分開兩個類別。

<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> 
相關問題