Hi Please help me, I have three tables, table3 contains table_Id and table1_Id, when I click the button I can retriev only table_Id values from the gllobal variable, I shoudl get table1_Id values also, how can I declare those as global variables ho can I retrieve table1_Id values .Thanks
var db = Titanium.Database.open('DB1'); var Qrows = db.execute('SELECT * FROM Table1'); while (Qrows.isValidRow()){ //Ti.App.questionsId = {questionsDesc:Qrows.fieldByName('Questions_Id')}; var questId = Qrows.fieldByName('table1_Id'); var questDesc = Qrows.fieldByName('table2_Desc'); //alert( Ti.App.questionsId.questionsDesc+"..."+Qrows.fieldByName('Questions_Id')); Qrows.next(); } //var l=0; var picker = Ti.UI.createPicker({ top:'18%', //visibleItems:4, useSpinner: true }); picker.selectionIndicator = true; self.add(picker); var pickerValues = []; var rows = db.execute('SELECT * FROM Table'); while (rows.isValidRow()) { pickerValues=Ti.UI.createPickerRow({ title:rows.fieldByName('table_Name'), id:rows.fieldByName('table_Id') }); picker.add(pickerValues); rows.next(); } picker.addEventListener('change',function(e){ Ti.App.tableId = {tableDesc:e.row.id}; infoBtn.title = 'info'; }); var infoBtn = Ti.UI.createButton({ top:(Titanium.Gesture.isPortrait()) ?'45%':'50%', //right:'15%', width:'35%', height:'5%', title:'Info' }); self.add(infoBtn); infoBtn.addEventListener('click',function(){ var db = Titanium.Database.open('DB1'); var dbRows = db.execute('SELECT * FROM Table3 WHERE table_Id = "'+Ti.App.tableId.tableDesc+'" And table1_Id = "'+questId+'" '); while (dbRows.isValidRow()) { var textField= Ti.UI.createWebView({ html:dbRows.fieldByName('table3_Desc'), top:'60%', width:'85%', height:'15%', left:'7%' // backgroundColor:'transparent', //backgroundImage:'../images/bg2.png' }); self.add(textField); dbRows.next(); } db.close(); });