0

I am developing an application with HTML5, MVC 4 ASP.NET. I want to implement a drop down with check boxes. I am able to do that,but I have two drop down, on the check of values of the first check box I want to refresh the options of the second Drop Down. I am using the following link http://acquisio.github.io/bootstrap-dropdown-checkbox/

But I am not able to reset the Drop Down. I am using $("myselector").dropdownCheckbox("reset", [{ ... }}]); But still not able to do it. Please help.

var tab2 = new Array();
       var selectobject = document.getElementById("ComboZone")
       for (var i = 0; i < selectobject.length; i++) {
           var obj = {label: selectobject.options[i].text, isChecked: false, id: selectobject.options[i].value};
           tab2.push(obj);
       }



       //$('.myDropdownCheckboxBasic').dropdownCheckbox({
       $('#ZoneDropDown').dropdownCheckbox({           
           data: tab2,
           autosearch: true,
           title: "My Dropdown Checkbox",
           hideHeader: false,
           showNbSelected: true,
           templateButton: '<a style="color:blue;text-align:center" class="dropdown-checkbox-toggle" data-toggle="dropdown" href="#">SELECT ZONE <span class="dropdown-checkbox-nbselected"></span></button>'
       });

<script type="text/javascript">
      function checkState(element) {                    
          var tab2 = new Array();
          var selectobject = document.getElementById("ComboRegion")
          for (var i = 0; i < selectobject.length; i++) {
              var obj = { id: selectobject.options[i].value, label: selectobject.options[i].text, isChecked: false };
              tab2.push(obj);         
}
          $("#RegDropDown").dropdownCheckbox("reset", tab2);




      }

  </script>

Thanks and Regards

48
  • what is ... in $("myselector").dropdownCheckbox("reset", [{ ... }}]); have you mention ids or not Commented Jan 15, 2014 at 8:38
  • Yes I have. It points to an array list that has the data Commented Jan 15, 2014 at 9:04
  • Above is the code, this is how I fill it Commented Jan 15, 2014 at 9:07
  • I checked the website, it says below is the way to reset the contents of Drop down $("myselector").dropdownCheckbox("reset", tab2); Commented Jan 15, 2014 at 9:08
  • i have tried with reset it is working fine Commented Jan 15, 2014 at 9:30

1 Answer 1

1
<script type="text/javascript">
      function checkState(element) {  
          var JQ = jQuery.noConflict();     
          var tab2 = new Array();
          var selectobject = document.getElementById("ComboRegion")
          for (var i = 0; i < selectobject.length; i++) 
           {
              var obj = { id: selectobject.options[i].value, label: selectobject.options[i].text, isChecked: false };
              tab2.push(obj);         
           }
          JQ ("#RegDropDown").dropdownCheckbox("reset", tab2);     
      }    
  </script>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.