I am trying to create an application where i will receive multiple JSON file in below format
{
"tname": [
{
"project_id" : "SC.0440",
"project_name" : "AAA - Testing",
"review_frequency" : "Monthly",
"planned_ipr_date" : "2016-02-16T18:30:00Z",
"actual_ipr_date" : "2016-02-16T18:30:00Z",
"contract" : "G",
"finance" : "G",
"delivery" : "G",
"people" : "G",
"process" : "G",
"project_rag" : "G",
"isms_compliance" : "G",
"bcms_compliance" : "G",
"description" : ""
}
]}
And i am taking two select fields in which i will display "tname" in one and on select of "tname" i will display all the key related to it in the other select box.i have done the part where i am getting key values for the first select box and trying to display key values inside it in other select field on change.
I have written a function to get all the key values based on the first selection where filePath() is a function which returns the path of the JSON files
function getColumn(keyval){
var arr = filePath();
var colnames = [];
$.each(arr, function (index, value){
$.getJSON(value,function(result){
$.each(result,function(key,field){
if(key == keyval){
$.each(field,function(key,field){
$.each(field,function(key,field){
colnames.push(key);
});
return false;
});
}else{
return false;
}
});
});
});
return colnames;
}
Now I want to display all the returned key values inside another select box.how i will achieve this using jquery?