SharePoint auto complete dropdown query after 2 characters typed in textbox

SharePoint list, jQuery autocomplete combobox after typing 2 characters it will query the list against those characters typed and populate the auto complete dropdown. the actual combobox code is should be taken from jQuery UI site.

function GetLastNames(prm)
{
$(“#LastName”).empty();
var SPTags =[];
var Available = 0;
var SPSMenu =”<ViewFields><FieldRef Name=’EmployeeFirstName’ /><FieldRef Name=’EmployeeLastName’ /></ViewFields>”;
$().SPServices({
operation: “GetListItems”,
async: true,
listName: “Assignments”,
CAMLViewFields: SPSMenu,
CAMLQuery: “<Query><Where><Contains><FieldRef Name=’EmployeeLastName’/><Value Type=’Text’>”+prm+”</Value></Contains></Where><OrderBy><FieldRef Name=’Title’ Ascending=’True’ /></OrderBy></Query>”,
completefunc: function (xData, Status) {
var ops =”<option value=”>–Select–</option>”;
$(xData.responseXML).SPFilterNode(“z:row”).each(function() {

var iID= $(this).attr(“ows_ID”);
var EmployeeLastName= $(this).attr(“ows_EmployeeLastName”);

ops = ops+”<option value='”+iID+”‘>”+EmployeeLastName+”</option>”;

});
$(“#LastName”).append(ops);
}
});

}

function checkITMan(vl)
{
lg = vl.length;
if(lg>=2)
{
GetLastNames(vl);
}
else
{
$(“#LastName”).empty();
}
}
</script>

Last Name:Select one…

 

 

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.