I have 2 variables in a script tag that get populated with string values.
I also have an .each loop that goes through each select box I have on the page. I want a way to append the index value of the loop to the name of the variable, and retrieve its value.
var secQuestion1 = "bla"
var secQuestion2 = "bla"
selectbox.each(function( index ) {
var question = ['secQuestion' + (index+1) ];
console.log("question = ", ['secQuestion' + (index+1)] )
});
I thought I might be able to use bracket notation to retrieve the value. Any ideas on how to do this, so on each index in the loop I would get my questions values?
selectbox