【问题标题】:Multiselect drop down not selecting multiple value多选下拉菜单不选择多个值
【发布时间】:2021-05-13 17:51:35
【问题描述】:

我正在尝试通过 Jquery Ajax(动态)绑定 Mutiselect 下拉菜单。

如果我将选择特定的用户数据,那么与用户相关的月份将只显示将从数据库中获取的月份,并且月份下拉菜单是多选的,无法选择多个值。尝试做级联

<select id="ddlMonth" name="ddlMonth[]" class="form-control" multiple="multiple">                              
</select>
   url: 'cascading.php',
   method: 'post',
   data: 'SBPMonthStudId=' + studid
}).done(function(studentsMonth){
    $('#ddlMonth').append(studentsMonth);
    $('#ddlMonth').multiselect({
    nonSelectedText:'Select Month',
    enableFiltering:true,
    buttonWidth:'100%'
});

在这种情况下,Mutiselect Dropdown 绑定正确但不能选择多个值

【问题讨论】:

    标签: php html jquery ajax


    【解决方案1】:

    如果你写这段代码会有什么结果?

    url: 'cascading.php',
    method: 'post',
    data: 'SBPMonthStudId=' + studid
    }).done(function(studentsMonth){
      $('#ddlMonth').empty();
      $('#ddlMonth').append("<option value='' disabled>--Select Month--</option>");
      $.each(studentsMonth, function(i,item){
        $('#ddlMonth').append('<option value="'+studentsMonth[i].id+'">'+studentsMonth[i].name+'</optoin>');
      });
    

    【讨论】:

      猜你喜欢
      • 2018-04-01
      • 2015-11-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多