Reputation: 2227
does anyone know a way to create a dropdown list as in a select statement that allows multiple selections but can display on one line. Adding the multiple="multiple" option causes it to display on as many lines as there are options which is not suitable for this project's layout Css and/or javascript would be fine however, hoping to avoid js frameworks. Thinking something with onclick event to show the standard multi-line dropdown box might work but not sure how to implement.
Following displays on several lines.
<select name="items[ ]" multiple="multiple">
<option value="item1">item1</option>
<option value="item2">item2</option>
<option value="item2">item2</option></select>
Upvotes: 5
Views: 11812
Reputation: 8524
I suggest to use select2 which gives you an easy possibility to create such a select-box you need. Example from that page fitting your needs:
$(".js-example-basic-multiple").select2();
<select class="js-example-basic-multiple" multiple="multiple">
<option value="AL">Alabama</option>
...
<option value="WY">Wyoming</option>
</select>
Upvotes: 3