Here is the code.
<script type="text/javascript" src="/_layouts/jquery/jquery-1.11.0.min.js"></script>
<script type="text/javascript" src="/_layouts/jquery/jquery-ui-1.10.4/jquery-ui.min.js"></script>
<script type="text/javascript" src="/_layouts/jquery/jquery.SPServices-2014.01.min.js"></script>
<link rel="stylesheet" type="text/css" href="/_layouts/jquery/jquery-ui-themes-1.10.4/themes/smoothness/jquery-ui.css"/>
<div class="ui-widget">
<label for="EmployeeCode">Job Code</label>
<input type="text" size="100" id="EmployeeCode">
<input type="button" value="OK" id="btnSearch" name="btnSearch" />
</div>
<script type="text/javascript">
$(document).ready(function(){
ExecuteOrDelayUntilScriptLoaded(PostLoad,'SP.js');
});
function PostLoad() {
// Hide Text Filter Control
var controlID = "ctl00_m_g_3c02ecf9_d389_42bf_ba2a_801aa56cf4af_SPTextSlicerValueTextControl";
document.getElementById("WebPartWPQ3").style.display='none';
$('#btnSearch').click(moveValue);
var externalParties = [];
window.onload = function() {
window.setTimeout(readyCall, 1000);
}
function readyCall(){
var externalParties = [];
$().SPServices({
operation: "GetListItems",
listName: "Employees",
CAMLViewFields: "<ViewFields> <FieldRef Name='EmployeeCode' /> <FieldRef Name='JobTitle' /> </ViewFields>",
async: false,
completefunc: function (xData, Status) {
$(xData.responseXML).SPFilterNode("z:row").each(function() {
externalParties.push($(this).attr("ows_EmployeeCode") + " -- " + $(this).attr("ows_JobTitle"));
});
}
});
$("#EmployeeCode").autocomplete({
source: externalParties,
minLength: 3
});
}
}
</script>
<script type="text/JavaScript">
function moveValue() {
var EmployeeCodeField = document.getElementById("EmployeeCode");
var otherControl = document.getElementById("ctl00_m_g_3c02ecf9_d389_42bf_ba2a_801aa56cf4af_SPTextSlicerValueTextControl");
//Making sure both fields are not undefined before accessing their properties.
if(EmployeeCodeField && otherControl){
var s = EmployeeCodeField.value;
s = s.substring(0, s.indexOf('--'));
otherControl.value = s.trim();
__doPostBack('<%= btnSearch.UniqueID %>','')
}else{
}
}
</script>