Suppose I have this JSON
let array = [
{
"Ids": "Sec 1",
"details": [
{
"id": "5ae82",
"Name": "John",
"currency": "$",
"amount": "100"
},
{
"id": "5ae821",
"Name": "Henary",
"currency": "$",
"amount": "100"
}
]
},
{
"Ids": "Sec 2",
"details": [
{
"id": "5ae83",
"Name": "Raes",
"currency": "$",
"amount": "100"
},
{
"id": "5ae821",
"Name": "Jass",
"currency": "$",
"amount": "100"
}
]
},
{
"Ids": "Sec 3",
"details": [
{
"id": "5ae831",
"Name": "Charles",
"currency": "$",
"amount": "100"
},
{
"id": "5ae841",
"Name": "Twitter",
"currency": "$",
"amount": "100"
}
]
},
]
How can I create a dropdown such that all the Ids
should be in the dropdown list based on the dropdown selection show its details? using javascript.
The problem I am facing is how can I create a dropdown from the array of objects.
let dd = document.getElementById("selectdd");
dd.innerHTML = array.map((item) =>
<option key={item.Ids} id=`${item.Ids}`>${item.Ids}</option>
);
How can I display the details based on ids selected?