2013-11-15 55 views
2

在這裏,我在dropdownchecklist顯示多個dropdownchecklist當下拉檢查表dynamicaly選擇項目

有一個問題,我想在dropdownchecklist選擇綁定一些項目,對於我使用下面的代碼:

var Ids = $("#selectedIds").val(); 
      if (Ids != "") { 
       // $('#AgeGroupIds1').dropdownchecklist('destroy');   
       $("#AgeGroupIds1").dropdownchecklist({ forceMultiple: true, width: 0 }); 
       var statusArray = new Array(); 
       var statusString = new String(); 
       statusString = Ids.toString(); 
       statusArray = statusString.split(','); 
       for (var i = 0; i < statusArray.length; i++) { 
        $("#AgeGroupIds1 option:[value='" + statusArray[i] + "']").attr('selected', 'selected'); 
       } 

      } 

      $("#AgeGroupIds1").dropdownchecklist({ 
       forceMultiple: true, 
       maxDropHeight: 190, 
       width: 220, 
       onComplete: function (selector) { 

        var pcids = ""; 
        for (i = 0; i < selector.options.length; i++) { 
         if (selector.options[i].selected && (selector.options[i].value != "")) { 
          if (pcids != "") pcids += ","; 
          pcids += selector.options[i].value; 
         } 
        } 
       } 
      }); 

我們的問題出多個dropdownchecklist

回答

0
var Ids = $("#selectedIds").val(); 
     if (Ids != "") { 
      // $('#AgeGroupIds1').dropdownchecklist('destroy');   
      $("#AgeGroupIds1").dropdownchecklist({ forceMultiple: true, width: 0 }); 
      var statusArray = new Array(); 
      var statusString = new String(); 
      statusString = Ids.toString(); 
      statusArray = statusString.split(','); 
      for (var i = 0; i < statusArray.length; i++) { 
       $("#AgeGroupIds1 option:[value='" + statusArray[i] + "']").attr('selected', 'selected'); 
      } 
      $("#ddcl-AgeGroupIds1").css("display", "none"); 
     } 

     $("#AgeGroupIds1").dropdownchecklist({ 
      forceMultiple: true, 
      maxDropHeight: 190, 
      width: 220, 
      onComplete: function (selector) { 

       var pcids = ""; 
       for (i = 0; i < selector.options.length; i++) { 
        if (selector.options[i].selected && (selector.options[i].value != "")) { 
         if (pcids != "") pcids += ","; 
         pcids += selector.options[i].value; 
        } 
       } 
      } 
     }); 
+0

你能解釋一下你做了什麼,這裏提供瞭解決方案OP問˚F要麼?你做了什麼改變?它做了什麼? – Zhihao

相關問題