0

I am using jQuery autocomplete, and its working great.

I would like to add an option "select all" to select all the result showed, Please check my code below :

$( "#prd" )
      .on( "keydown", function( event ) {
        if ( event.keyCode === $.ui.keyCode.TAB &&
            $( this ).autocomplete( "instance" ).menu.active ) {
          event.preventDefault();
        }
      })
      .autocomplete({
        source: function( request, response ) {
          $.getJSON( "php/productsList.php", {
            term: extractLast( request.term )
          }, response );
        },
        search: function() {
          // custom minLength
          var term = extractLast( this.value );
          if ( term.length < 2 ) {
            return false;
          }
        },
        focus: function() {
          // prevent value inserted on focus
          //return false;
            $(this).find('#prd').select(); $(this).select();
        },
        select: function( event, ui ) {
          var terms = split( this.value );
          // remove the current input
          terms.pop();
          // add the selected item
          terms.push( ui.item.value );
          // add placeholder to get the comma-and-space at the end
          terms.push( "" );
          this.value = terms.join( ", " );
          return false;
        },
        close : function (event, ui) {
            if (!$("ul.ui-autocomplete").is(":visible")) {
                $("ul.ui-autocomplete").show();
            }
        }
      });

Thanks in advance for your help.

Shiladitya
  • 12,003
  • 15
  • 25
  • 38
allam
  • 3
  • 1
  • Possible duplicate of [Select mutiple options from jquery autocomplete with checkboxes](https://stackoverflow.com/questions/40673329/select-mutiple-options-from-jquery-autocomplete-with-checkboxes) – Muhammad Omer Aslam Dec 03 '17 at 18:59
  • Thank you for the comment, unfortunetly I have saw that post before posting my question, It's not about the same problem I don't want add checkbox, all I need is to add an option to select all result. – allam Dec 04 '17 at 12:49

0 Answers0