Fix some enhancements & new features
This commit is contained in:
18
build/js/include/form/set_options.js
Normal file
18
build/js/include/form/set_options.js
Normal file
@@ -0,0 +1,18 @@
|
||||
function setOptions(selector,data,selected,all) {
|
||||
// console.log(data);
|
||||
var $el = $(selector);
|
||||
$el.empty(); // remove old options
|
||||
if (all) {
|
||||
$el.append($("<option></option>").attr("value",'').text('Tous'));
|
||||
}
|
||||
$.each(data, function(key, name) {
|
||||
console.log(name);
|
||||
if (key != null) {
|
||||
if (key == selected) {
|
||||
$el.append($("<option selected='selected'></option>").attr("value", key).text(name));
|
||||
} else {
|
||||
$el.append($("<option></option>").attr("value", key).text(name));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user