AutoComplete using JQuery

Here are step by step to implement Jquery Auto Complete :

1. Download the files

2. Add this script into your page:

 <script src="<%= ResolveClientUrl("~/js/jquery/jquery-1.4.1.min.js") %>" type="text/javascript"></script>

<script src="<%= ResolveClientUrl("~/js/AutoComplete/jquery.autocomplete.js") %>" type="text/javascript"></script>
 
   
        <script type="text/javascript">
            $(function(){
             var data = '<%=searchChar%>'.split(";");
            $("#ctl00_ContentPlaceHolder1_ucTxtSearch_txtSearch").autocomplete(data);
            });
      </script>
    <link rel="stylesheet" href="~/css/AutoComplete/jquery.autocomplete.css"  type="text/css" />

 

"<%=searchChar%>" , is the variable sent from behind code, contains suggestion criteria data. It should be spilted by ";" char.

"#ctl00_ContentPlaceHolder1_ucTxtSearch_txtSearch", is clientID, it depends on your component ID.

 

Oke then, may it helps.

No comments:

Post a Comment