Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/400.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用aspx和javascript的jquerymultiselect问题_Javascript_Jquery_Asp.net_Multi Select - Fatal编程技术网

使用aspx和javascript的jquerymultiselect问题

使用aspx和javascript的jquerymultiselect问题,javascript,jquery,asp.net,multi-select,Javascript,Jquery,Asp.net,Multi Select,我正在使用multiselect的插件:Bootstrap multiselect() 这是我在aspx head中的列表框: <script type="text/javascript"> $(function () { $('[id*=LB_Kostenart]').multiselect({ includeSelectAllOption: false, enableF

我正在使用multiselect的插件:Bootstrap multiselect()

这是我在aspx head中的列表框:

  <script type="text/javascript">
        $(function () {
            $('[id*=LB_Kostenart]').multiselect({
            includeSelectAllOption: false,
            enableFiltering: false,
            filterPlaceholder: 'Suchen...',
            nonSelectedText: 'Kostenart wählen',
            allSelectedText: 'Alle',
            selectAllText: 'Alle',
            numberDisplayed: 1,
            maxHeight: 150
        });
    });
</script>

$(函数(){
$('[id*=LB_Kostenart]')。多选({
includeSelection:false,
启用筛选:false,
filterPlaceholder:'苏晨…',
非选举文本:“Kostenart wählen”,
allSelectedText:“Alle”,
选择AllText:'Alle',
显示的数字:1,
最大高度:150
});
});
这很好用。我尝试将所选选项限制为仅一个。这是插件页面上的示例:

<script type="text/javascript">
$(document).ready(function() {
    $('#example-limit').multiselect({
        onChange: function(option, checked) {
            // Get selected options.
            var selectedOptions = $('#example-limit option:selected');

            if (selectedOptions.length >= 4) {
                // Disable all other checkboxes.
                var nonSelectedOptions = $('#example-limit option').filter(function() {
                    return !$(this).is(':selected');
                });

                nonSelectedOptions.each(function() {
                    var input = $('input[value="' + $(this).val() + '"]');
                    input.prop('disabled', true);
                    input.parent('li').addClass('disabled');
                });
            }
            else {
                // Enable all checkboxes.
                $('#example-limit option').each(function() {
                    var input = $('input[value="' + $(this).val() + '"]');
                    input.prop('disabled', false);
                    input.parent('li').addClass('disabled');
                });
            }
        }
    });
});

$(文档).ready(函数(){
$(“#示例限制”).multiselect({
onChange:函数(选项,选中){
//获取选定的选项。
var selectedOptions=$(“#示例限制选项:selected”);
如果(selectedOptions.length>=4){
//禁用所有其他复选框。
var nonSelectedOptions=$(“#示例限制选项”).filter(函数(){
return!$(this).is(':selected');
});
非选择选项。每个(函数(){
var input=$('input[value=“”+$(this.val()+”);
input.prop('disabled',true);
input.parent('li').addClass('disabled');
});
}
否则{
//启用所有复选框。
$(“#示例限制选项”)。每个(函数(){
var input=$('input[value=“”+$(this.val()+”);
input.prop('disabled',false);
input.parent('li').addClass('disabled');
});
}
}
});
});
我还复制了aspx页面头部的代码,并用
[id*=LB_Kostenart]
更改了
#示例限制
,但这不起作用。使用F12,我发现在运行
MainContent\u LB\u Kostenart
时会调用列表框。但这也不起作用。 对于
onChange
函数,我必须使用的正确名称是什么?谢谢