1

I am using the JQUERY Autocomplete and am trying to limit the number of choices to 10 at any time. I am not sure how to limit what the user sees. Can any one help?

The dropdown should only display at most 10 names... I am not sure how to accomplish this. The autocomplete is activated after 1 character is typed in..

$(function() {


     $( "#search" ).autocomplete({
        source:[
               {"label":"ALEX - A111","movie_id":"A111","name":"ALEX"},
               {"label":"AL - A112","movie_id":"A112","name":"AL"},
               {"label":"JON - A113","movie_id":"A113","name":"JON"},
               {"label":"JOE - A114","movie_id":"A114","name":"JOE"},
               {"label":"TOM - A115","movie_id":"A115","name":"TOM"},
               {"label":"TED - A116","movie_id":"A116","name":"TED"},
               {"label":"TESS - A117","movie_id":"A117","name":"TESS"},
               {"label":"SAM - A118","movie_id":"A118","name":"SAM"},
               {"label":"RON - A119","movie_id":"A119","name":"RON"},
               {"label":"RICK - A120","movie_id":"A120","name":"RICK"},
               {"label":"CAM - A121","movie_id":"A121","name":"CAM"},
               {"label":"LUCY - A122","movie_id":"A122","name":"LUCY"},
               {"label":"TIM - A123","movie_id":"A123","name":"TIM"},
               {"label":"ERIC - A124","movie_id":"A124","name":"ERIC"},
               {"label":"KERRY - A125","movie_id":"A125","name":"KERRY"},
               {"label":"AMY - A126","movie_id":"A126","name":"AMY"},
               {"label":"GREG - A127","movie_id":"A127","name":"GREG"},
               {"label":"MIKE - A128","movie_id":"A128","name":"MIKE"},
               {"label":"BILL - A129","movie_id":"A129","name":"BILL"},
               {"label":"BOB - A130","movie_id":"A130","name":"BOB"}
               ],


        minLength: 1, //search after one characters


        focus: function(event, ui) {
            $("#search").val(ui.item.label);
            return false;
        },

        change: function(event, ui) {
                if (!ui.item) {
                     alert("You must select a 'Member' from the drop-down list.");
                     $("#search").val('');
                     $("#search").focus();
                     $("#name").val('');
                return false;
                }
         },

        select: function( event, ui ) {
                    event.preventDefault();
                    $('#search').val(ui.item.label);
                    this.value = ui.item.label;

                    $('#name').val(ui.item.movie_id);

        }
    });
});

dfsq
  • 191,768
  • 25
  • 236
  • 258
Ronald
  • 557
  • 1
  • 9
  • 26
  • Check this out: https://stackoverflow.com/questions/7617373/limit-results-in-jquery-ui-autocomplete – dfsq Jan 19 '18 at 15:15

0 Answers0