I’m trying to filter data from JSON in JavaScript.
I define a variable a
. I want the property of whatever value a
is equal to (not item.a
). So far I’ve been unable to find a way of doing it.
Everything else is working correctly because when I changed it to a specific entry (item.date for example) it works fine. I cannot figure out the correct syntax.
while(i< elements.length){
var a=elements[i].id;
if(elements[i].name == 'targetfeild'){
$(elements[i]).val($.map(result,function(item){var test = elements[i].id;return item.a;}));
}
i++;
}