我有一个带复选框的多选下拉菜单。我想在变量和警报弹出窗口中获取选定的值。在下拉列表中,每当我选中这些复选框时,我都会带有一些带有复选框的值,我希望这些选定的值位于变量中。请让我知道如何实现这一目标。找到下面的代码。
<script>
var colors = [
{ Name: "jQuery/HTML5/ASP.NET MVC Controls" },
{ Name: "ASP.NET Controls" },
{ Name: "Windows Forms Controls" },
{ Name: "WPF Controls" },
{ Name: "Android Native mobile controls" },
{ Name: "iOS Controls" },
{ Name: "SharePlus" },
{ Name: "ReportPlus" },
{ Name: "Indigo Studio" }
];
$(function () {
$("#singleSelectCombo").igCombo({
width: 300,
dataSource: colors,
textKey: "Name",
valueKey: "Name",
dropDownOnFocus: true,
dropDownOrientation: "bottom"
});
$("#multiSelectCombo").igCombo({
width: 300,
dataSource: colors,
textKey: "Name",
valueKey: "Name",
multiSelection: {
enabled: true
},
dropDownOrientation: "bottom"
});
$("#checkboxSelectCombo").igCombo({
width: 300,
dataSource: colors,
textKey: "Name",
valueKey: "Name",
multiSelection: {
enabled: true,
showCheckboxes: true,
},
dropDownOrientation: "bottom"
});
});
$(document).ready(function() {
$(".btn").click(function() {
var colors = [];
$.each($("input[Name='colors']:checked"), function() {
colors.push($(this).val());
});
});
});
</script>