I\'m trying to get this to work:
function whatever(arg) {
eval(arg) + \'_group\' = [];
}
The purpose is to have only 1 function instead h
function whatever(arg) {
window[arg + '_group'] = [];
}
This will set a_group
, b_group
as global variable.
To access those variable use:
window['a_group'], window['b_group']
and so on.
In your switch
you should use break;
.
switch(field_name) {
case 'states':
use = 'state';
break;
case 'cities':
use = 'city';
break;
case 'neighborhoods':
use = 'neighborhood';
break;
}
var myObject = {};
function whatever(arg) {
myObject[arg + '_group'] = [];
// output: { 'a_group' : [], 'b_group' : [], .. }
}
// to set value
myObject[arg + '_group'].push( some_value );
// to get value
myObject[arg + '_group'];