diff --git a/htdocs/lib/ajax.lib.php b/htdocs/lib/ajax.lib.php index cfc508f383b..2fa6da8bb1f 100644 --- a/htdocs/lib/ajax.lib.php +++ b/htdocs/lib/ajax.lib.php @@ -147,11 +147,23 @@ function ajax_multiautocompleter($htmlname,$fields,$url,$option='') //alert(fields + " " + length); jQuery("input#'.$htmlname.'").autocomplete({ - source: function( request, response ) { - jQuery.getJSON( "'.$url.($option?'?'.$option:'').'", { '.$htmlname.': request.term }, response ); - }, - dataType: "json", + dataType: "json", minLength: 2, + source: function( request, response ) { + jQuery.getJSON( "'.$url.($option?'?'.$option:'').'", { '.$htmlname.': request.term }, function(data){ + response( jQuery.map( data, function( item ) { + if (data.length == 1) { + jQuery("#'.$htmlname.'").val(item.value); + for (i=0;i