I am working on a PHP, JS site. I need a dynamic JS array key.
var list = '';
for(i in data)
{
var list += '<li><a>'+data[i].fieldname_usa+'</a></li>';
}
here I want the key to be dynamic
Ex: var country = "usa"
the key would be fieldname_usa
var country = "uk";
the key would be fieldname_uk
I am trying to achieve this by
var country = "usa";
var list += '<li><a>'+data[i].fieldname_+country+'</a></li>';
Because I use different databases for different countries and the filed names would be different in each country .
But seems like it process data[i].fieldname_
as the key. so my finalist put is undefinedusa
or undefineduk
.