$obj = new Object();
$obj.surname = "smith";
$field_name = "surname";
alert($obj.$field_name); //error!!
Wth? How do I do this with js? I need to access all values in an object within a foreach but I can’t manage to access obj proprerties by reference!
$obj[$field_name]will do. It’s the same with the literal keys: you may useobject['id']as well asobject.id– the latter is shorter, though. )