I'm looking to output specific JSON data in an HTML table with JavaScript. The headers will remain the same, but the JSON content will vary.
Currently, I have a working function that generates the entire table using JavaScript:
<body>
<input type="button" onclick="CreateTableFromJSON()" value="Test Output" />
<p id="showData"></p>
</body>
<script>
function CreateTableFromJSON() {
var myData = [JSON DATA GOES HERE]
// Code for header values
// Generating the table
}
</script>
If you only want to display columns for "label" and "userData", you can modify the script accordingly.
The current JSON sample includes various fields, but we aim to print out just "label" and "userData":
[{"type":"paragraph","subtype":"p","label":"Paragraph"}, ...]
Instead of displaying all fields, you should see a table similar to this: