$(document).ready(function () { $('#automobile').change(function () { var automobile = $(this).val(); if (automobile == '0') { $('#model').html(''); $('#model').attr('disabled', true); $('#y_start').html(''); $('#y_start').attr('disabled', true); return(false); } $('#model').attr('disabled', true); $('#model').html(''); var url = 'get_model.php'; $.get( url, "automobile=" + automobile, function (result) { if (result.type == 'error') { alert('error'); return(false); } else { var options = ''; $(result.models).each(function() { options += ''; }); $('#model').html(''+options); $('#model').attr('disabled', false); $('#y_start').html(''); $('#y_start').attr('disabled', true); } }, "json" ); }); $('#model').change(function () { var model = $(this).val(); //$('#model :selected').val(); //alert (model); if (model == '0') { $('#y_start').html(''); $('#y_start').attr('disabled', true); return(false); } $('#y_start').attr('disabled', true); $('#y_start').html(''); var url = 'get_yar.php'; $.get( url, "y_start=" + model, function (result) { if (result.type == 'error') { alert('error'); return(false); } else { var options = ''; $(result.y_starts).each(function() { options += ''; }); $('#y_start').html(''+options); $('#y_start').attr('disabled', false); $('#y_start').change(function(){ var value = $('#y_start :selected').text(); var y_start = $('#y_start :selected').val(); if (y_start !== '0') { $('#selectBoxInfo').html(''). fadeIn(1000,function(){ location.replace("/podbor/"+ y_start); }); } }); } }, "json" ); }); });