在下拉列表中选择以逗号分隔的多个复选框选项

时间:2017-06-19 07:21:14

标签: jquery angularjs

find the image here

在下拉列表中选择多个选项,在下拉列表中选中一个复选框,并在下拉列表中以逗号分隔显示

onselecting a checkbox and display with comma separated on dropdown

1 个答案:

答案 0 :(得分:1)

您可以使用bootstrap-multiselect和jquery来实现目标。它适用于片段。



$(function() {
  $('#yourselect').multiselect({
      includeSelectAllOption: true
  });
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://davidstutz.github.io/bootstrap-multiselect/dist/css/bootstrap-multiselect.css" rel="stylesheet"/>
<link href="https://davidstutz.github.io/bootstrap-multiselect/docs/css/bootstrap-3.3.2.min.css" rel="stylesheet"/>
<script src="https://davidstutz.github.io/bootstrap-multiselect/docs/js/bootstrap-3.3.2.min.js"></script>
<script src="https://davidstutz.github.io/bootstrap-multiselect/dist/js/bootstrap-multiselect.js"></script>

<form id="form1">
  <div>
    <select id="yourselect" multiple="multiple">
      <option value="cheese">Cheese</option>
      <option value="tomatoes">Tomatoes</option>
      <option value="mozarella">Mozzarella</option>
    </select>
  </div>
</form>
&#13;
&#13;
&#13;