2
0
forked from Wavyzz/dolibarr

New: add vat rate in supplier price

New: add events system in jquery combobox
This commit is contained in:
Regis Houssin
2012-03-15 16:52:18 +01:00
parent d296f17f36
commit e8ec5f5ad7
9 changed files with 180 additions and 80 deletions

View File

@@ -202,17 +202,41 @@ function ajax_dialog($title,$message,$w=350,$h=150)
* Convert a select html field into an ajax combobox
*
* @param string $htmlname Name of html field
* @param array $event Event options
* @return string Return html string to convert a select field into a combo
*/
function ajax_combobox($htmlname)
function ajax_combobox($htmlname, $event=array())
{
$msg.= '<script type="text/javascript">
$(function() {
$("#'.$htmlname.'" ).combobox();
});
</script>';
$msg.= "\n";
$("#'.$htmlname.'").combobox({
selected : function(event,ui) {
var obj = '.json_encode($event).';
$.each(obj, function(key,values) {
if (values.method.length) {
getMethod(values);
}
});
}
});
function getMethod(obj) {
var id = $("#'.$htmlname.'").val();
var method = obj.method;
var url = obj.url;
var htmlname = obj.htmlname;
$.get(url,
{
action: method,
id: id,
htmlname: htmlname
},
function(response) {
$("select#" + htmlname).html(response);
});
}
});';
$msg.= "</script>\n";
return $msg;
}