0

Can anyone suggest a link or solution to add select All option within the multiselect dom element of the material design. I want all the options to be selected except for the select all option and want to display it in the text field and post it.

I couldn't find a solution for it. Can anyone suggest. Pls Note: I dont want to add it as a button outside the dom.

    $("#all_member").change(function(){

  if($("#all_member option[value=-1]:selected").length > 0){
      $('#all_member option').attr('selected', "selected"); 
      $('#all_member').prev("ul").find("li").addClass('active'); 
      $('#all_member').prev("ul").find("li span input").attr('checked', "true"); 
  }else{
      $('#all_member option').attr('selected', "false"); 
      $('#all_member').prev("ul").find("li").removeClass('active'); 
      $('#all_member').prev("ul").find("li span input").removeAttr('checked'); 
  }

Thanks IN advance!

DpGp
  • 121
  • 1
  • 13

1 Answers1

0

I can provide the logic. The rest is up to you.

  1. Put an onChange event handler (function) for your select.
  2. On that function, put an "if statement" to check if the value is equal to the value of "Select All" option.
  3. If it returns true, then manually call the element and set its value to the value of all the other options (probably an array).
Giovanni Lobitos
  • 852
  • 7
  • 19
  • thats exactly what i have been doing and this logic works only once but doesnt later for the same event. can anyone find any issue here. Thanks! I have edited the question with my code. – DpGp Jul 29 '16 at 16:02
  • can anyone help me out here, still stuck and not able to move ahead, the only problem here is the lokk and feel of the dropdown doesnt show up the tick on second time – DpGp Aug 02 '16 at 16:25