<label for="multiSelect"
class="control-label">负责人</label>
<div class="controls">
<select class="multiSelect" name="manager"
style="width:200px">
<option
>tom</option>
<option
>admin</option>
<option
>alex</option>
</select>
</div>
<label for="input01" class="control-label"
>项目成员</label>
<div class="controls">
<select name="worker"
id="worker" multiple class="multiSelect" style="width:400px">
<option
>tom</option>
<option
>admin</option>
<option
>alex</option>
</select>
</div>
<input type="hidden"
name="workers" id="workers"/>
<div class="form-actions">
<button type ="button"
id="btnSave"class="btn
btn-primary">保存</button>
</div>
javaScript的导入
<script type="text/javascript"
src="js/jquery.min.js"></script>
<script type="text/javascript"
src="js/select/select2.min.js"></script>
<script
type="text/javascript">
$(document).ready(function(){
$(".multiSelect").select2();
$("#btnSave").click(function(){
var v =$("#worker").select2("val");
$("#workers").val(v);
$("#myform").submit();//myform表单的id
});
});
</script>