0

I am using following code to auto-complete the text field,

$(function() {
    var availableTags = [
                <?php 
                foreach($botname as $row)
                {
                echo "'".$row->plsal_name_botanical."-".$row->pot_code."',"; 
                }?>
                        ];
    $( "#botname" ).autocomplete({
        source: availableTags
    });
});

As the result array is huge. How to write code to give a limit to display suggestion.

Piyush
  • 3,947
  • 9
  • 36
  • 69

1 Answers1

1

You can split no of result as bellow:

$(function() {
    var availableTags = [ <? php
        foreach($botname as $row) {
            echo "'".$row - > plsal_name_botanical.
            "-".$row - > pot_code.
            "',";
        } ?>
    ];

});
$("#botname").autocomplete({
    source: function(request, response) {
        var results = $.ui.autocomplete.filter(availableTags, request.term);

        response(results.slice(0, 10));
    }
});
Mox Shah
  • 2,967
  • 2
  • 26
  • 42