For the sake of keeping this question limited, here is an example from W3Schools that I extended to give an idea of what I am trying to accomplish.
HTML:
<p id="demo"></p>
JS
var objA = [
{ "name":"John", "age":30, "city":"New York"},
{ "name2":"John2", "age2":302, "city2":"New York2"}
];
document.getElementById("demo").innerHTML = objA.name;
This prints undefined. What am I doing wrong?
Thanks!
After review... I have this now...
<p id="demo"></p>
<p id="demo2"></p>
for(var i=0;i < objA.length;i++){
document.getElementById("demo").innerHTML += objA[i]["name"];
document.getElementById("demo2").innerHTML += objA[i]["name"];
}
if I leave the =+ in, it prints both JohnJohn2 in both p tags. If I remove the +, it prints just John2 in both tags. The first p tag should print john, and the second should print john2