put auotcompete in function as to reuse it

put auotcompete in function as to reuse it

Hi
 
 
I have Autocomplete as below. I need to wrap them into a function and pass two parameters for   "#txtValue" and "#lblName"  so that I  can reuse  it as many as I can as I have one page which need to call ten times  the  differences are only the imput  ("#txtValue") and the label ("#lblName")
 
thanks you very much in advance
 
$( "#txtValue" ).autocomplete({

minLength: 4,

autoFocus: true ,

source: function (request,response) {

$.ajax({

url: ' @Url.Action( "Autocomplete" , "File" ) ' ,

dataType: "json" ,

data: { term: request.term },

success: function (data) {

response($.map(data, function (item) {

return { label: item.Region, value: item.RegionID };

}))

}

})

},

  select: function (event, ui) {

$( "#txtValue" ).val(ui.item.value);

$( "#lblName" ).val(ui.item.label);

return false ;

}

});