2012-11-27 1 views
0

안녕하세요 저는 배열의 배열에 대한 작은 질문을 가지고 ... EX를 호출하는 방법 :jQuery를 배열

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

는 배열의 모든 전화와 그들 각각에 기능을 프리폼 나는 각각의 jQuery 함수를 사용할 것이다.

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

지금은 제 3 VAR이 필요하기 때문에 같은 배열의 내부 배열 갖고 싶어 :

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

를 내 문제는 내가 두 번째 발은 "bearSheva"호출하는 방법입니다 배열 내부의 첫 번째 배열

당신의 도움을 주셔서 감사합니다 나의 나쁜 영어 :

답변

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 
    }); 
}); 

희망 하시겠습니까?