diff --git a/htdocs/lib/ajax.lib.php b/htdocs/lib/ajax.lib.php index 4fbda426200..a40e9129094 100644 --- a/htdocs/lib/ajax.lib.php +++ b/htdocs/lib/ajax.lib.php @@ -92,8 +92,13 @@ function ajax_autocompleter($selected='',$htmlname,$url,$option='') source: function( request, response ) { jQuery.get("'.$url.($option?'?'.$option:'').'", { '.$htmlname.': request.term }, function(data){ response( jQuery.map( data, function( item ) { - var label = item.label.toString().replace(new RegExp("("+request.term+")","i"),"$1"); - return { label: label, value: item.value, id: item.key} + if (data.length == 1) { + jQuery("#search_'.$htmlname.'").val(item.value); + jQuery("#'.$htmlname.'").val(item.key); + } else { + var label = item.label.toString().replace(new RegExp("("+request.term+")","i"),"$1"); + return { label: label, value: item.value, id: item.key} + } })); }, "json"); },