最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - HTMLPHP one line dropdown list multiple selection - Stack Overflow

programmeradmin5浏览0评论

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>

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>
Share Improve this question edited Apr 24, 2012 at 19:09 user1260310 asked Apr 24, 2012 at 17:00 user1260310user1260310 2,23710 gold badges49 silver badges67 bronze badges 1
  • (Very) similar to stackoverflow./questions/4753407/… – RustyTheBoyRobot Commented Jul 5, 2012 at 20:36
Add a ment  | 

2 Answers 2

Reset to default 3

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>

See size attribute.

<select multiple="multiple" size="1">
发布评论

评论列表(0)

  1. 暂无评论