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

does anyone know a way to create a dropdown list as in a select statement that allows multiple selectio

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744314766a4568124.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信