I have a collection of predetermined variables. I dynamically assign a value to another variable, which ends up representing the name of one of the predefined variables. This allows me to easily determine which set variable to use on a particular section of the page.
var mwm = "blah"
var vp = "bleh"
var am = "bluh"
var mwm720 = "some link 1"
var mwm717 = "some link 2"
var vp720 = "some link 3"
var vp717 = "some link 4"
...
Subsequently, there are other scripts that run and assign a variable value based on certain conditions, corresponding to the names of those predefined variables.
var myClass = $(this).attr("class").split(' ')[1];
var currDiv = "div." + myClass;
var currVersion = $(this).parent().attr("id");
var linkVers = myClass + currVersion;
The value of the variable linkVers always turns out to be "mwm720", "mwm717", "vp720", etc. This mechanism helps determine when to utilize the mwmw720 or mwm717 (etc) variables.
Intended Outcome
I am seeking guidance on how to prompt/trigger the utilization of the actual value stored in the dynamic variable that corresponds to the variable name.
If alert(linkVers);
produces "mwm720", how can I ensure that $(currDiv).html(linkVers);
inserts the value associated with the mwm720 variable (which would be "some link 1"), rather than just the variable name itself?
If there is an alternative approach to achieving this objective, I am open to exploring different solutions.