$(document).ready(function(){
    
   $("[class*=_autocomplete]").each(function(){
        autofill($(this).attr('id'), $(this).attr('class').replace('_autocomplete',''));
    });
});
function autofill(id, iclass)
{
    $('#'+id).autocomplete({
        source: "/autofill/" + iclass,
        minLength: 1,
        sroll: true,
        maxRows: 20,
        select: function (event, ui) {
            //populate hidden input
            $('#'+id.replace('_search','')).val(ui.item.id);
            
        }
    });
}

