Hi everyone, may I know how do I use the Ti.App.Properties to retrieve my information from the database once I clicked the submit button and it will loop so that everytime I clicked the submit button, it will loop to the next question from my database.
var self = Titanium.UI.currentWindow; var db = Ti.Database.install('quizDB1.sqlite', 'quizDB'); db = Ti.Database.open("quizDB"); var questionRS = db.execute('SELECT QuestionRecordId,QuestionText,ChoiceText1,ChoiceText2,ChoiceText3,CorrectChoice, Score FROM BTTQuestion WHERE QuestionRecordId = ' + Ti.App.Properties.getString('questionRecordID')); var questionTableData = []; var questionText = questionRS.fieldByName('QuestionText'); var choiceText1 = questionRS.fieldByName('ChoiceText1'); var choiceText2 = questionRS.fieldByName('ChoiceText2'); var choiceText3 = questionRS.fieldByName('ChoiceText3'); var correctChoice = questionRS.fieldByName('CorrectChoice'); var questionTableRow = Ti.UI.createTableViewRow({height:100,className:'forumEvent'}); var questionRecordId = questionRS.fieldByName('QuestionRecordId'); var labelQuestion = Ti.UI.createLabel({color:'#000',backgroundColor:'yellow',font:{fontsize:'28'},width:200}); labelQuestion.text = questionText; Ti.App.Properties.setString ('newQuestion' + 2); var submitbtn = Titanium.UI.createButton({ top : '37.5%', left : "40%", height : "30%", width : "40%", backgroundImage : 'Images/submitbtn.png' }); var radioButton2 = Titanium.UI.createButton({ top : '37.5%', left : "40%", height : "30%", width : "40%", backgroundImage : 'Images/rdBtn_Selected.png' }); questionTableRow.add(labelQuestion);//add the new labelQuestion into the questionTableRow questionTableData.push(questionTableRow); //add the nw questionTableRow into the questionTableData questionTableRow = Ti.UI.createTableViewRow({height:100,className:'forumEvent'}); var labelChoice1 = Ti.UI.createLabel({color:'#000',backgroundColor:'white',font:{fontsize:'28'},width:200}); labelChoice1.text = choiceText1; if (correctChoice=="1"){labelChoice1.isCorrect=1;}else{labelChoice1.isCorrect=0;} radioButton2.addEventListener('click',function(e){ radioButton2.backgroundImage = 'Images/rdBtn_Selected.png'; if (choiceText1.isCorrect=="1"){ alert('Your choice is right'); }else{ alert('Your choice is wrong') ; } }) questionTableRow.add(labelChoice1);//add the new labelChoice into the questionTableRow questionTableData.push(questionTableRow); //add the nw questionTableRow into the questionTableData questionTableRow = Ti.UI.createTableViewRow({height:100,className:'forumEvent'}); var labelChoice2 = Ti.UI.createLabel({color:'#000',backgroundColor:'white',font:{fontsize:'28'},width:200}); labelChoice2.text = choiceText2; if (correctChoice=="2"){labelChoice2.isCorrect=1;}else{labelChoice2.isCorrect=0;} questionTableRow.addEventListener('click',function(e){ if (e.row.children[0].isCorrect=="1"){ alert('Your choice is right'); }else{ alert('Your choice is wrong') ; } }) questionTableRow.add(labelChoice2);//add the new labelChoice into the questionTableRow questionTableData.push(questionTableRow); //add the nw questionTableRow into the questionTableData questionTableRow = Ti.UI.createTableViewRow({height:100,className:'forumEvent'}); var labelChoice3 = Ti.UI.createLabel({color:'#000',backgroundColor:'white',font:{fontsize:'28'},width:200}); labelChoice3.text = choiceText3; if (correctChoice=="3"){labelChoice3.isCorrect=1;}else{labelChoice3.isCorrect=0;} questionTableRow.addEventListener('click',function(e){ if (e.row.children[0].isCorrect=="1"){ alert('Your choice is right'); }else{ alert('Your choice is wrong') ; } }) questionTableRow.add(labelChoice3);//add the new labelChoice into the questionTableRow questionTableData.push(questionTableRow); //add the nw questionTableRow into the questionTableData var tableView = Ti.UI.createTableView({backgroundColor:'white',data:questionTableData}); self.add(tableView); self.add(submitbtn); submitbtn.addEventListener('click',function(e){ //var window = Ti.UI.createWindow({ Ti.App.Properties.getString('newQuestion'), //url : 'details.js', //backgroundColor: 'black', //fullscreen: false, //}); window.open(); });