Hello i need some help as my array is not showing everything display
The picture show there 3 array data but however one is display only as this is the on i written to display for 1 i have included a for loop but it seems not working here my code for it
i have JSON.phase to it call responses
This is my array response
[{"Recyclable": "unknown recyclable name"},{"Recyclable": "some recyclable name"},{"Recyclable": "another recyclable"}]
This is my code
const responses = JSON.parse(user.CdsRecyclables)
document.getElementById('name').value = "" + responses[0]["Recyclable"]
for (let i = 0; i < responses.length; i++) {
responses[i]["Recyclable"] + "<br>";
}
<div class="container-body ">
<fieldset class="Field">
<label id="symbol">-><input id="name" disabled></label>
</fieldset>
</div>
Try this code and let me know if this solves your problem
let responses = [{"Recyclable": "unknown recyclable name"},{"Recyclable": "some recyclable name"},{"Recyclable": "another recyclable"}]
let field = document.querySelector(".Field");
let str = "";
for (let i = 0; i < responses.length; i++) {
response = "" + responses[i]["Recyclable"]
str += `
<label id="symbol">-><input id="name" disabled value="${response}"></label><br/>
`;
field.innerHTML = str;
console.log(response)
}