Html: Select Multiple As Dropdown

I would lượt thích to use a select field with multiple as a comtháng dropdown field with size=1:

123 456 789Why doesn"t this code show the arrow for the dropdown?

Thanks!


*

*

A similar question was asked here

If you"re able to lớn add an external library to lớn your project, you can try Chosen

Here"s a sample:


$(".chosen-select").chosen( no_results_text: "Oops, nothing found!") American Black Bear Asiatic Black Bear Brown Bear Giant Panda Sloth Bear Sun Bear Polar Bear Spectacled Bear

*

*

Because you"re using multiple. Despite it still technically being a dropdown, it doesn"t look or act like a standard dropdown. Rather, it populates a menu box and lets them select multiple options.

Bạn đang xem: Html: select multiple as dropdown

Size determines how many options appear before they have khổng lồ cliông xã down or up to lớn see the other options.

I have sầu a feeling what you want lớn achieve is only going khổng lồ be possible with a JavaScript plugin.

Some examples:

jQuery multiselect drop down menu

http://labs.abeautifulsite.net/archived/jquery-multiSelect/demo/


*

It"s quite unpractical to lớn make multiple select with size 1. think about it. I made a fiddle here: https://jsfiddle.net/wqd0yd5m/2/

123 456 789Try to lớn explore other options such as using checkboxes lớn achieve your goal.


Here is the documentation of . You are using 2 attributes:

multiple This Boolean attribute indicates that multiple options can be selected in the list. If it is not specified, then only one option can be selected at a time. When multiple is specified, most browsers will show a scrolling các mục box instead of a single line dropdown.

Xem thêm: Phát Hiện Sớm Ung Thư Về Tiêu Hóa : Nguy Hiểm Nhất Trong Các Loại Ung Thư

size If the control is presented as a scrolling các mục box (e.g. when multiple is specified), this attribute represents the number of rows in the các mục that should be visible at one time. Browsers are not required to lớn present a select element as a scrolled list box. The default value is 0.

As described in the docs. will render a List box only 1 line visible và a scrollbar. So you are loosing the dropdown/arrow with the multiple attribute.


You probably need lớn some plugin lượt thích Jquery multiselect dropdown. Here is a test.

Also you need khổng lồ cđại bại your option tags lượt thích this:

123 456 789JSFIDDLE DEMO


$(".chosen-select").chosen( no_results_text: "Oops, nothing found!") American Blaông xã Bear Asiatic Blaông chồng Bear Brown Bear Giant Pandomain authority Sloth Bear Sun Bear Polar Bear Spectacled Bear
Thanks for contributing an answer to Staông xã Overflow!

Please be sure khổng lồ answer the question. Provide details and tóm tắt your research!

But avoid

Asking for help, clarification, or responding to lớn other answers.Making statements based on opinion; baông xã them up with references or personal experience.

To learn more, see our tips on writing great answers.


Post Your Answer Discard

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy & cookie policy


Not the answer you're looking for? Browse other questions tagged html drop-down-menu or ask your own question.


site design / hình ảnh sản phẩm © 2021 Staông chồng Exchange Inc; user contributions licensed under cc by-sa. rev2021.7.9.39692


Your privacy

By clicking “Accept all cookies”, you agree Stachồng Exchange can store cookies on your device & discthảm bại information in accordance with our Cookie Policy.