Title: Auto Complete using JSOM
Description:
I have a requirement that. Data there in a list and need to show the matched data when ever i type a letter. To full fil the requirement use the Auto complete.

Steps:
Creat a Sharepoint list calld Infolist
Create a column called "Company" in a list
Code:
<html>
<head>
<script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/4.0/1/MicrosoftAjax.js"></script>
<script type="text/javascript" src="/_layouts/15/init.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.runtime.js"></script>
<script type="text/javascript" src="/_layouts/15/sp.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<link href = "https://code.jquery.com/ui/1.10.4/themes/ui-lightness/jquery-ui.css" rel = "stylesheet">
<script src = "https://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<script>
var sArray = [];
$(function() {
Mainloop();
$( "#autoPopulateTextBox" ).autocomplete({
source: sArray
});
});
function Mainloop()
{
ExecuteOrDelayUntilScriptLoaded(retrieveListItems, "sp.js");
}
function retrieveListItems()
{
var clientContext = new SP.ClientContext();
var oList = clientContext.get_web().get_lists().getByTitle('Infolist');
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml("<View></View>");
this.collListItem = oList.getItems(camlQuery);
clientContext.load(collListItem);
clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded),Function.createDelegate(this, this.onQueryFailed));
}
function onQuerySucceeded(sender, args)
{
var listItemInfo = '';
var listItemEnumerator = collListItem.getEnumerator();
while (listItemEnumerator.moveNext())
{
var oListItem = listItemEnumerator.get_current();
sArray.push(oListItem.get_item("Company"));
}
}
function onQueryFailed(sender, args)
{
alert('Request failed.')
}
</script>
</head>
<input type="text" id="autoPopulateTextBox" />
</html>
Description:
I have a requirement that. Data there in a list and need to show the matched data when ever i type a letter. To full fil the requirement use the Auto complete.
Steps:
Creat a Sharepoint list calld Infolist
Create a column called "Company" in a list
Code: