我想從多維數組中獲取值。這是我迄今爲止所擁有的。
當我選擇數組中的第一個選項時,我需要99的值和圖像,例如「比利喬爾」。JavaScript:如何從多維數組中獲取值?
var concertArray = [
["Billy Joel", "99", "equal.png"],
["Bryan Adams", "89", "higher.png"],
["Brian Adams", "25", "lower.png"]
];
function populate(){
for(i = 0; i < concertArray.length; i++){
var select = document.getElementById("test");
select.options[select.options.length] = new Option(concertArray[i][0], concertArray[i][1]);
}
}
非常感謝.... 現在,什麼話我必須做的,完成concertImage在這種結構: concertName = concertList.options [concertIndex]的.text; concertPrice = parseFloat(concertList.options [concertIndex] .value); concertImage = ??? – kentrenholm 2012-04-22 20:45:20