var self = Ti.UI.currentWindow;
self.backgroundColor = '#333';
// create view
var view = Ti.UI.createView();
var myFont = {fontSize: 18};
var myHeight = 50;
var myWidth = '80%';
var cols = [20, 300];
var rows = [20, 50, 120, 150, 220];
var nameLbl = Ti.UI.createLabel({text:"Name: ", left:cols[0], top: rows[0], width:myWidth, font:myFont});
view.add(nameLbl);
var nameTxt = Ti.UI.createTextField({hintText :"Enter your name", left:cols[0], top: rows[1], width:myWidth, font:myFont})
view.add(nameTxt);
var ageLbl = Ti.UI.createLabel({text:"Age: ", left:cols[0], top: rows[2], width:myWidth, font:myFont});
view.add(ageLbl);
var ageTxt = Ti.UI.createTextField({hintText :"Enter your age", left:cols[0], top: rows[3], width:myWidth, font:myFont})
view.add(ageTxt);
var button = Ti.UI.createButton({title: 'Add Data', top: rows[4], left:cols[0], height:myHeight});
view.add(button);
button.addEventListener('click', function(e){
// get data
// install db in device
var db = Ti.Database.install('/mydata/mydb.sqlite', 'mydb');
var rows = db.execute('INSERT INTO hello_tbl (name, age) VALUES (?,?)',
nameTxt.value, ageTxt.value);
Ti.API.info("data added: " + nameTxt.value + " , " + ageTxt.value);
self.close();
})
self.add(view);
self.backgroundColor = '#333';
// create view
var view = Ti.UI.createView();
var myFont = {fontSize: 18};
var myHeight = 50;
var myWidth = '80%';
var cols = [20, 300];
var rows = [20, 50, 120, 150, 220];
var nameLbl = Ti.UI.createLabel({text:"Name: ", left:cols[0], top: rows[0], width:myWidth, font:myFont});
view.add(nameLbl);
var nameTxt = Ti.UI.createTextField({hintText :"Enter your name", left:cols[0], top: rows[1], width:myWidth, font:myFont})
view.add(nameTxt);
var ageLbl = Ti.UI.createLabel({text:"Age: ", left:cols[0], top: rows[2], width:myWidth, font:myFont});
view.add(ageLbl);
var ageTxt = Ti.UI.createTextField({hintText :"Enter your age", left:cols[0], top: rows[3], width:myWidth, font:myFont})
view.add(ageTxt);
var button = Ti.UI.createButton({title: 'Add Data', top: rows[4], left:cols[0], height:myHeight});
view.add(button);
button.addEventListener('click', function(e){
// get data
// install db in device
var db = Ti.Database.install('/mydata/mydb.sqlite', 'mydb');
var rows = db.execute('INSERT INTO hello_tbl (name, age) VALUES (?,?)',
nameTxt.value, ageTxt.value);
Ti.API.info("data added: " + nameTxt.value + " , " + ageTxt.value);
self.close();
})
self.add(view);
No comments:
Post a Comment