window.onload = function(){ const addRow = function(building){ //Populate First table cell: Building Name $nameElement = $("") .attr("id", `${building.id}-progress.name`) .append(building.name); //Populate table cell: Use $useElement = $("") .attr("id", `${building.id}-progress.use`) .append(building.use) //Populate table cell: Designed $designedElement = $("") .attr("id", `${building.id}-progress.designed`) .addClass("checkboxCell") .append($("") .attr("type", "checkbox") .attr("id", `${building.id}.designed?`) .attr("checked", building.designed)); //Populate table cell: Started $startedElement = $("") .attr("id", `${building.id}-progress.stated`) .addClass("checkboxCell") .append($("") .attr("type", "checkbox") .attr("id", `${building.id}.started?`) .attr("checked", building.started)); //Populate table cell: Completed $completedElement = $("") .attr("id", `${building.id}-progress.completed`) .addClass("checkboxCell") .append($("") .attr("type", "checkbox") .attr("id", `${building.id}.completed?`) .attr("checked", building.completed)); //Populate table cell: Populated $populatedElement = $("") .attr("id", `${building.id}-progress.populated`) .addClass("checkboxCell") .append($("") .attr("type", "checkbox") .attr("id", `${building.id}.populated?`) .attr("checked", building.populated)); //Create entire row, appending all elements $outputRow = $("") .attr("id", `${building.id}-progress`) .append($nameElement) .append($useElement) .append($designedElement) .append($startedElement) .append($completedElement) .append($populatedElement); //return the entire row return $outputRow; } console.info("loading"); $.getJSON("./resources/spawn/buildings.json", "", function(file){ for(const buildingName in file.buildings){ $("#progress-table").append(addRow(file.buildings[buildingName])); } }); }