38 lines
870 B
JavaScript
Executable File
38 lines
870 B
JavaScript
Executable File
$(document).ready(function() {
|
|
function resetFilter() {
|
|
$('#select_2').html('');
|
|
}
|
|
|
|
function changeSelect(obj) {
|
|
var value = obj.val();
|
|
var id_select = obj.data('id-family');
|
|
|
|
if (value != 0) {
|
|
$.ajax({
|
|
url : '/modules/categoryfamily/ajax.php',
|
|
type : 'POST',
|
|
data : 'id_select='+id_select+'&id_parent='+value,
|
|
dataType : 'json',
|
|
success : function(json, statut){
|
|
if (json.errors == false) {
|
|
if( $('#select_'+json.id_select).length == 1) {
|
|
$('#select_'+json.id_select).html(json.data);
|
|
} else {
|
|
$('#select_'+json.id_before).after(json.data);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
} else {
|
|
resetFilter();
|
|
}
|
|
}
|
|
|
|
$('#family_1').live('change', function(e){
|
|
changeSelect($(this));
|
|
});
|
|
$('#family_2').live('change', function(e){
|
|
changeSelect($(this));
|
|
});
|
|
|
|
}); |