var brands_2nd_selector = $(".brands_2nd_select");
var series_2nd_selector = $(".series_2nd_select");
var models_2nd_selector = $(".models_2nd_select");
var lang_select_brands = '-- Manufacturer --';
var lang_select_series = '-- Series --';
var lang_select_models = '-- Model --';
var lang_loading = 'Loading ...';
var first_option_brands = '';
var first_option_series = '';
var first_option_models = '';
var selector_width = '100%';
var use_cache = true;
brands_2nd_selector.select2({
placeholder: lang_select_brands,
allowClear: true,
width: selector_width,
}).on("change", function(){
$('.container-search-models').html(loading);
series_2nd_selector.select2({'placeholder':lang_loading,width: selector_width});
$.ajax({
type: "GET",
url: '/app.php?a=interface&m=seriesList',
cache: use_cache,
data: 'rt_list=1&brand_id='+brands_2nd_selector.select2('val'),
success: function(data) {
series_2nd_selector.html(data.split('|')[0]).select2({'placeholder':lang_select_series,allowClear: true,width: selector_width}).prop("disabled", false);
$('.container-search-models').html(data.split('|')[1]);
models_2nd_selector.html(first_option_models).prop("disabled", true);
if (brands_2nd_selector.select2('val') == null || brands_2nd_selector.select2('val') == '') {
series_2nd_selector.prop("disabled", true);
}
}
});
});
series_2nd_selector.select2({
placeholder: lang_select_series,
allowClear: true,
width: selector_width,
}).on("change", function(){
$('.container-search-models').html(loading);
models_2nd_selector.select2({'placeholder':lang_loading,width: selector_width});
$.ajax({
type: "GET",
url: '/app.php?a=interface&m=modelsList',
cache: use_cache,
data: 'rt_list=1&brand_id='+brands_2nd_selector.select2('val')+'&series_id='+series_2nd_selector.select2('val')+'&is_cpu='+$('#product_type').val(),
success: function(data) {
models_2nd_selector.html(data.split('|')[0]).select2({'placeholder':lang_select_models,allowClear: true,width: selector_width}).prop("disabled", false);
$('.container-search-models').html(data.split('|')[1]);
if (series_2nd_selector.select2('val') == null || series_2nd_selector.select2('val') == '') {
models_2nd_selector.prop("disabled", true);
}
}
});
}).prop("disabled", true);
models_2nd_selector.select2({
placeholder: lang_select_models,
allowClear: true,
width: selector_width,
}).on("change", function(){
$.ajax({
type: "GET",
url: '/app.php?a=interface&m=redirectDetailPage',
cache: use_cache,
data: 'id='+models_2nd_selector.select2('val'),
success: function(data) {
$(window.location).attr('href', data);
}
});
}).prop("disabled", true);