2013-08-29 40 views
-1

我試圖做一個系統,我可以得到兩個具體的價值 例如:j = 8和j = 5但它不想請幫助我!由於如何獲得兩個!數組的具體值在JavaScript中?

for (var val in resultats[j].Nom + 1 + 1 + 1 + 1 + 1) { 
    $('<option />', { 
     value: resultats[5].Nom & resultats[8].Nom , 
     text: resultats[5].Nom & resultats[8].Nom 
    }).appendTo(dropDownList); 
    j++; 
} 
+8

你將不得不解釋你想要做得更清楚。 – Paulpro

+0

我試圖得到不同位置的數組上的值,如選項卡[我],其中我= 5和我= 8只!!!!索引5和8. –

回答

1

您是否希望只使用在循環resultats[5]resultats[8]?試試這個:

var keys = [5,8]; 
for (var i = 0; i < keys.length; i++) 
{ 
    resultat = resultats[keys[i]]; 
    $('<option />',{ 
    value: resultat.Nom, 
    text: resultat.Nom 
    }).appendTo(dropDownList); 
} 
+0

謝謝! :)我會試穿它! –

+0

是我在找! resultats [5]和resultats [8] :) –

+0

謝謝!!!!有用! :)我關閉了我的問題。 –

相關問題