I have a variable with a value, let’s say
var myVarMAX = 5;
In HTML I have an element with id="myVar".
I combine the id with the string MAX (creating a string myVarMAX). My question is how can I use this string to access a variable with the same name?
You COULD use eval, but if you have the var in the window scope, this is better
However Don’t pollute the global scope!
A better solution is something like what is suggested in the link I posted
then you have
alert(myVars[“myVar”+id]);