diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index e68fe78bc87..79ceb73d05a 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -25,8 +25,9 @@ /** - * Get value of an HTML field, do Ajax process and show result. + * Generic function that return javascript to add to a page to transform a common input field into an autocomplete field by calling an Ajax page (ex: /societe/ajaxcompanies.php). * The HTML field must be an input text with id=search_$htmlname. + * This use the jQuery "autocomplete" function. * * @param string $selected Preselecte value * @param string $htmlname HTML name of input field @@ -34,7 +35,7 @@ * @param string $urloption More parameters on URL request * @param int $minLength Minimum number of chars to trigger that Ajax search * @param int $autoselect Automatic selection if just one value - * @param array $ajaxoptions Multiple options array (Ex: array('update'=>array('field1','field2'...)) will reset field1 and field2 once select done + * @param array $ajaxoptions Multiple options array (Ex: array('update'=>array('field1','field2'...)) will reset field1 and field2 once select done) * @return string Script */ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLength=2, $autoselect=0, $ajaxoptions=array()) @@ -182,25 +183,28 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt } /** - * Get value of field, do Ajax process and return result + * Generic function that return javascript to add to a page to transform a common input field into an autocomplete field by calling an Ajax page (ex: core/ajax/ziptown.php). + * The Ajax page can also returns several values (json format) to fill several input fields. + * The HTML field must be an input text with id=$htmlname. + * This use the jQuery "autocomplete" function. * - * @param string $htmlname Name of field - * @param string $fields other fields to autocomplete - * @param string $url Chemin du fichier de reponse : /chemin/fichier.php + * @param string $htmlname HTML name of input field + * @param string $fields Other fields to autocomplete + * @param string $url URL for ajax request : /chemin/fichier.php * @param string $option More parameters on URL request * @param int $minLength Minimum number of chars to trigger that Ajax search * @param int $autoselect Automatic selection if just one value * @return string Script */ -function ajax_multiautocompleter($htmlname,$fields,$url,$option='',$minLength=2,$autoselect=0) +function ajax_multiautocompleter($htmlname, $fields, $url, $option='', $minLength=2, $autoselect=0) { $script = ''."\n"; $script.= '