javascript - for loop in multidimensional array on a selector for car shop -


i have selector car shop of make, model , year.

it no work fine... can select alfa romeo , audi cars.

i think problem on inner loop.

$.each(carjson.marca, function (index, value) { $("#marca").append('<option value="' + value.id + '">' + value.name + '</option>'); 

});

$('#marca').on('change', function () { console.log($(this).val() ); // marca.id

for (var = 0; < carjson.marca.length; i++) {     if (carjson.marca[i].id == $(this).val()) {         $('#model').html('<option value="000">-model-</option>');         $.each(carjson.marca[i].model, function (index, value) {         $("#model").append('<option value="' + value.id + '">' + value.name + '</option>');                           });      }      $('#model').on('change', function(){     console.log($(this).val() );     (var b=0; b < carjson.marca.length ; b++)    {              ( var c=0; c < 2 ; c++) {          //for ( var c=0; c < carjson.marca[b].model.length ; c++) {             if(carjson.marca[b].model[c].id == $(this).val()){          $('#eng').html('<option value="000">-motorsss!-</option>');          $.each(carjson.marca[b].model[c].engine, function (index, value) {          $("#eng").append('<option value="' + value.id + '">' + value.name + '</option>');          });                     }     } } 

} );

}  

});

i attached code in jsfiddle: http://jsfiddle.net/leqtn/ in advance.


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -