I have this function to dynamically create a list from an array
function fill1(arr) {
var out = "";
var i;
for(i = 0; i < arr.length; i++) {
var a=arr[i].code;
var b=arr[i].name;
out += '<li><a href="" onclick="myfunction(this)" id="'+arr[i].code+'" value="'+arr[i].name+'">' +
b + '</a></li>';
}
document.getElementById("instrumental").innerHTML = out;
}
and this function for alert
function myfunction(elem) {
var x=elem.id;
var c=document.getElementById(x).value;
alert(c);
}
When I alert x its ok but when i alert c its showing undefined
aelement does not have a.valueproperty. Nor is itsvalueattribute valid.valueis not valid, it becomes a custom attribute.. May be accessed bygetAttribute("value")