Using this json input:
[
{
"tableName": "data",
"attributes": [
{
"id": "att1"
},
{
"id": "att2"
},
{
"id": "att3"
},
{
"id": "att8"
}
]
}
]
I have two select dropdowns, in the first dropdown I get the tableNames from my json file, so the first dropdown has values of data, data1, data2, etc and the user would select a table by selecting its "tableName". In my second dropdown I want only the attribute ids from the previously selected tableName from the first dropdown. I am stuck at this part, as it still iterates through the whole dataset instead of just the attributes of a single data. This isn't correct but this is what I currently have, it just gets the first attribute for all of my datasets
$(document).ready(function () {
var url = "listData.json";
$.getJSON(url, function (data) {
console.log(data);
$('#dropdown-1').append('<option selected="true" disabled>Select Data</option>');
var i = 0;
$.each(data, function (index, value) {
// APPEND OR INSERT DATA TO SELECT ELEMENT.
$('#dropdown-1').append('<option value>' + value.attributes[i].id + '</option>');
i++;
});
});
});