javascriptjqueryselectmultiple-select

HTML Select Box show as Multiple, but to Disable Multiple Selection?


I needed to have:

Then it is showing correctly as:

<select id="gagaga" multiple>
    <option>A</option>
    <option>B</option>
    <option>C</option>
</select>

How can i make it non-multiple selectable (to allow only 1 selection)?


Solution

  • Use this size="3"

    <!DOCTYPE html>
    <html>
    <body>
    <select id="gagaga" size="3">
        <option>A</option>
        <option>B</option>
        <option>C</option>
    </select>
    </body>
    </html>
    

    If the value of the size attribute is greater than 1, but lower than the total number of options in the list, the browser will add a scroll bar to indicate that there are more options to view.