<!DOCTYPE html>
<html>
<body>
<h2>TEST - t5 - </h2>
<p>] reading a json file that contains an array of 'Employee Requirement Items' records</p>
<p id="totalCount" style="text-indent:50px"></p>
<p>] every Booking Seat aka (Entity Booking) record has a reference to the Emp Req Template Id and the ? Emp Req Item Id ?</p>
<p id="demo" style="text-indent:50px"></p>
<p>] Now, lets create a subset of records that all contain the same Req Template Id </p>
<p id="subset1Count" style="text-indent:50px"></p>
<script>
//
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
// alert(this.readyState + "- " + this.status); // returns 1, 4, returns 0, 0
if (this.readyState == 4 && this.status == 200) {
var myArr = JSON.parse(this.responseText);
// alert(myArr); // Object object
// var list = null;
var myArr2 = [];
var count = 0;
// document.getElementById("demo").innerHTML = myArr[0];
myArr2 = myArr.map(function(elm,idx){
count++;
return elm = elm + "-" + count;
})
var maxCount = count;
document.getElementById("demo").innerHTML = myArr2 ;//+ "Total:" + maxCount;
document.getElementById("totalCount").innerHTML = "There are " + maxCount +" records in this file/these file(s)";
document.getElementById("subset1Count").innerHTML = "There are " + myArr2.length +" records in this subset";
}
};
xmlhttp.open("GET", "json_demo_array.txt", true);
xmlhttp.send();
</script>
</body>
</html>