for loop ALL Records, Stringify, List
<html><head>
<title> for loop through ALL Records, Stringify, List </title>
<script src="record.js"></script>
</head>
<body>
<script>
function renderHtml()
{
var jsonOutputDiv = document.getElementById("theJsonOutput");
var output = '';
for(var i = 0; i < myRecord.length; i++)
{
output += '<li>' +myRecord[i].name+ '</li>';
}
jsonOutputDiv.innerHTML = output;
}
</script>
<button id="insertIt" onclick="renderHtml()">Insert to page</button>
<div id="theJsonOutput"></div>
</body>
</html>
<title> for loop through ALL Records, Stringify, List </title>
<script src="record.js"></script>
</head>
<body>
<script>
function renderHtml()
{
var jsonOutputDiv = document.getElementById("theJsonOutput");
var output = '';
for(var i = 0; i < myRecord.length; i++)
{
output += '<li>' +myRecord[i].name+ '</li>';
}
jsonOutputDiv.innerHTML = output;
}
</script>
<button id="insertIt" onclick="renderHtml()">Insert to page</button>
<div id="theJsonOutput"></div>
</body>
</html>
//save as record.js
var myRecord = [
{
name: "Key",
height: "5 feet 9 3/4 inches",
weight: 140,
eyeColor: "Brown",
nationality: "French, Irish"
},
{
name: "Donald",
height: "6 feet 4 inches",
weight: 160,
eyeColor: "Blue",
nationality: "Ukrainian, French"
}
];
var myRecord = [
{
name: "Key",
height: "5 feet 9 3/4 inches",
weight: 140,
eyeColor: "Brown",
nationality: "French, Irish"
},
{
name: "Donald",
height: "6 feet 4 inches",
weight: 160,
eyeColor: "Blue",
nationality: "Ukrainian, French"
}
];