Dynamically Select Variable

Viewed 2774

I have 2 variables like so

var variable_1 = "foo";
var variable_2 = "bar";

I use a function to grab the value of a checkbox input and for each checkbox which is checked, I want to load the particular variable which depends on value of checkbox.

$("input:checked").each(function() {
    $(div).append('variable_'+$(this).val());
}

So I'd concatenate the text 'variable_' with the value of each checkbox.

Thanks!

4 Answers
Related