I am using javascript to populate a select box in my page but its not working, the select box displays but its completely empty.
I also get no error in my console.
My script is this:
var select = document.createElement("select");
for(var i in resource){
if(i !== id && select.hasOwnProperty(i)){
select.setAttribute(i, resource[i].name);
}
}
d.appendChild(select);
Example data for resource:
{
"1":{"name":"Test"},
"2":{"name":"Test2"},
"3":{"name":"Test3"}
}
Any ideas on why it won't populate?
iwill be the object such as resource[1] etc