Home > DeveloperSection > Forums > How to use autocomplete in jquery
Pawan Shukla

Total Post:37

Points:267
Posted on    September-28-2016 6:02 AM

 JQuery JQuery 
Ratings:


 1 Reply(s)
 362  View(s)
Rate this:
I want to use jquery autocomplete search box in my project . Please help me by giving a demo .


aditya kumar Patel

Total Post:250

Points:1782
Supported
Posted on    September-28-2016 6:18 AM

This is a jQuery method used in modern websites to provide the user with a list of suggestions for the beginning of the word he has typed in a text box. The user can then select an item from the list, which will be displayed in the input field. This feature prevents the user from having to enter an entire word.

jQueryUI provides an autocomplete widget—a control that acts a lot like a <select> dropdown, but filters the choices to present only those that match what the user is typing into a control. jQueryUI provides the autocomplete() method to create a list of suggestions below the input field and adds new CSS classes to the elements concerned to give them the appropriate style

Syntax

<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

<div class="ui-widget">
    <label for="tags">Search: </label>
    <input id="tags">
</div>
<script>
    $(function () {
        var SearchData = [
            "AngularJs",
            "KnockoutJs",
            "Asp",
            "BASIC",
            "C",
            "C++",
            "Clojure",
            "COBOL",
            "ColdFusion",
            "C#",
            "VB",
            "SQL",
            "Haskell",
            "Java",
            "JavaScript",
            "Lisp",
            "Perl",
            "PHP",
            "Python",
            "Ruby",
            "Scala",
            "Scheme"
        ];

        $("#tags").autocomplete({
            source: SearchData
        });
    });
</script>
thanks.

Modified On Sep-28-2016 06:21:39 AM

Don't want to miss updates? Please click the below button!

Follow MindStick