I have a page where I want to see if a certain value exists in one of the arrays I have defined, there is one main array and several “sub” arrays, they are defined like this:
var main = ['header', 'firstname', 'surname', 'tel'];
var firstname_label = ['Hank', 'Dave', 'Erin', 'Jessica'];
var surname_label = ['Michaels', 'McHankering', 'Jameson', 'Lloydd', 'Eagon', 'Philips'];
var tel_label = ['mobile', 'landline'];
I want to check the sub arrays with a variable I have, I was thinking something along these lines:
for (i=1;i<=mainCount;i++)
{
jQuery.inArray(var_x, main[i]_label)
}
Is something like this possible?
Try using an
Object:The alternative would be to use
evalto select the variable name, but don’t go there.