2012-11-27 39 views
0

大家好我對自己在陣的陣一個小問題以及如何調用它... EX:jQuery的數組中的數組

var plotName = ['bearShevaPlot', 'haifaPlot', 'tiberiasPlot', 'kfarSabaPlot', 'netanyaPlot', 'rishonLezionPlot', 'rehovotPlot', 'telAvivPlot']; 
var chartName = ['bearShevaCity', 'haifaCity', 'tiberiasCity', 'kfarSabaCity', 'netanyaCity', 'rishonLezionCity', 'rehovotCity', 'telAvivCity']; 

調用所有的數組和他們每個人大跳功能我將使用.each jQuery函數。

$.each(plotName,function(cName,pName){ 
    chartName[cName]; 
    var pName = $.jqplot(''+chartName[cName]+'', [/* another var */], { 
      //my code here 
    }); 
}); 

,因爲我需要有一個第三個變種我想有一個像數組裏的數組:

var plotName = [['bearShevaPlot', 'bearSheva'], ['haifaPlot', 'haifa'], ['tiberiasPlot', 'tiberias'], ['kfarSabaPlot', 'kfarSaba'], ['netanyaPlot', 'netanya'], ['rishonLezionPlot', 'rishonLezion'], ['rehovotPlot', 'rehovot'], ['telAvivPlot', 'telAviv']]; 

,我的問題是,我怎麼能叫「bearSheva」這是第二次VAL數組內的第一個數組。

感謝您的幫助,我的英語不好:)

回答

0

firstPlot & secondPlot對不起具有所需的值。

var chartName = ['bearShevaCity', 'haifaCity', 'tiberiasCity', 'kfarSabaCity', 'netanyaCity', 'rishonLezionCity', 'rehovotCity', 'telAvivCity']; 
var plotName = [['bearShevaPlot', 'bearSheva'], ['haifaPlot', 'haifa'], ['tiberiasPlot', 'tiberias'], ['kfarSabaPlot', 'kfarSaba'], ['netanyaPlot', 'netanya'], ['rishonLezionPlot', 'rishonLezion'], ['rehovotPlot', 'rehovot'], ['telAvivPlot', 'telAviv']]; 

$.each(plotName,function(cName,pName){ 
    var chart = chartName[cName]; 
    var firstPlot = pName[0]; 
    var secondPlot = pName[1]; 
    var pName = $.jqplot(''+chartName[cName]+'', [/* another var */], { 
      //my code here 
    }); 
}); 

希望它有幫助。