I am looking to create a multidimensional array in JavaScript to store questions along with their related options. Here is my current code snippet:
demoArray[i] = new Array();
var id=results.rows.item(i).del_ques_id;
demoArray[i]["question"] = results.rows.item(i).question;
demoArray[i]["id"] = results.rows.item(i).del_ques_id;
tx.executeSql('SELECT option,value,del_opt_id FROM delta_option WHERE del_ques_id='+results.rows.item(i).del_ques_id+' order by value desc', [], getOptionDetails, errorCB);
function getOptionDetails(tx,results){
console.log("option query");
var lent = results.rows.length;
console.log("DEMO table: " + lent + " rows found.");
for(var j=0;j<lent;j++){
demoArray[i]=new Array();
demoArray[i]["option"]=results.rows.item(j).option;
}
}
I need help with creating an array structure like this within the same demoArray:
1{
ques: question_string;
id: question_id;
option:{
option_name: option_string;
option_id: option_id_string;
}
}
2{
..
..
} and so on
This is the desired structure for my array. Can someone assist me with the code for achieving this?