json multidimensional array listdown jquery for car shop -
i'm trying listdown selector choose car model user of shop. not access models of second trademark. not work audi a3-a4 model. don't know i'm doing wrong. appreciate push. in advance lot ! attached code in jsfiddle: http://jsfiddle.net/uc8ft/1/
i think error in code:
$('#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>'); }); } } } } ); more specifically, in loops "for" or last "each".
replace inner loop
for ( var c=0; c < 2 ; c++) {
with
for ( var c=0; c < carjson.marca[b].model.length ; c++) {
Comments
Post a Comment