1

i have this code below, but doesn't work. how i can set a variable as a multiple array index?

var tamanho = $(this).html();
var tamanhoNormal = { 
                    'P' : {'A' : 67,'L' : 50},
                    'M' : {'A' : 70,'L' : 52},
                    'G' : {'A' : 72,'L' : 54},
                    'GG' : {'A' : 75,'L' : 58}
                };
alert(tamanhoNormal.tamanho.A);

I really don't know how to do it. Thanks for any help

Dênis Fernandes
  • 174
  • 2
  • 11

1 Answers1

2

Supposing tamanho is "P", "M", "G" or "GG", then use

alert(tamanhoNormal[tamanho].A);
Denys Séguret
  • 372,613
  • 87
  • 782
  • 758