I've been struggling with creating HTML selectors and retrieving their values from JSON. I attempted to read the JSON data by adding a script tag to the HTML document and parsing it into a variable using JavaScript. However, this approach didn't seem to work as expected, and the solutions I found online were not very helpful.
Here is the HTML setup:
<body>
<form>
<label>Select list</label>
<select id = "Countries">
</select>
<select id = "Bands">
</select>
<select id = "Albums">
</select>
</form>
<script src="data.json"></script>
<script src="script.js"></script>
</body>
And the JavaScript code snippet:
const data = JSON.parse(data);