因为工作需要,引入combobox多选下拉框,并且获取选择的值并以","分开。
效果如下:
代码如下:
<html>
<head>
<title>
easyui-combobox多选
</title>
<link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/themes/default/easyui.css">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.6.min.js">
</script>
<script type="text/javascript" src="http://www.jeasyui.com/easyui/jquery.easyui.min.js">
</script>
</head>
<body>
<select id="combobox" data-options="multiple:true,panelHeight:'auto'"
class="esayui-combobox" style="width:200px;">
<option value="AL">
Alabama
</option>
<option value="AK">
Alaska
</option>
<option value="AZ">
Arizona
</option>
<option value="AR">
Arkansas
</option>
<option value="CA">
California
</option>
<option value="CO">
Colorado
</option>
</select>
</body>
<script type="text/javascript">
$('#combobox').combobox({
onChange: function() {
var value = $('#combobox').combobox('getValues');
console.log(value);
console.log(value.join(','));
alert(value);
}
});
</script> </html>