[sans doute bete] transformer une chaine en variable.
Bonjour tlm :), voila mon problème :
Code:
1 2 3 4 5 6
|
var qttproduit1 = 1; //nombre
var qttproduit2 = 3; //nombre
var identifiant = "produit1"
//ou
var identifiant = "produit2"; //chaine, change selon l'évènement |
je veux obtenir au final
Code:
1 2 3 4 5 6
|
quantite = qttproduit1;
//ou :
quantite = qttproduit2; //selon l'évènement
//donc
quantite = "qtt"+identifiant; |
sauf que si je fais ça évidement quand je fais un alert(quantite); j'obtiens la chaine "qttproduit1" ou "qttproduit2" et nom pas 1 ou 3.
D'ou ma question, comment transformer une chaine en nom de variable?
Merci d'avance, j'espère avoir été clair :)