jeudi 26 février 2015

Uncaught TypeError: undefined is not a function on getAttribute method

I have a function where I need to get the 'id' of an element in an array (county).



function returnCountyId(){
var countyName = findCountyMatchFromServer();
var foundCounty = county.findBy('title', countyName);
var countyId = foundCounty.getAttribute('id');
return countyId
}


I find the name (countyName) but somehow



foundCounty.getAttribute('id');


returns error: Uncaught TypeError: undefined is not a function


Rest of the code:



function findCountyMatchFromServer(){
var county = getElementAsString("ddlCounty");
return county;
};

var county = [{
id: '1',
title: "Harjumaa",
avgPrice: '1234',
avgSurface: '23',
}, {
id: '2',
title: 'Hiiumaa',
avgPrice: '5345',
avgSurface: '243',
}]


Thank you!





Aucun commentaire:

Enregistrer un commentaire