Hi,
I'm trying to create an application for users to take part in a survey with the use of an SQL databse. So far I have created the code to give me the value of a TextField of one of the questions using a switch statement. However, how do I make titanium give me 2 different values for 2 different questions using a while loop?
~~~
while (questionRows.isValidRow()){
var questionlabel = Titanium.UI.createLabel({
top: 90,
left: 10,
font: {fontSize:20},
text: questionNo + '. '+questionRows.fieldByName('question'),
color: 'black',
touchEnabled: false
});
switch (questionType) {
case 1:
var answerBox = Ti.UI.createTextField({
borderRadius:5,
font: {fontSize:20, fontWeight:'bold'},
//textAlign:'left',
hintText:'Type your answer here',
keyboardType: Titanium.UI.KEYBOARD_DEFAULT,
top:200,
width:300,
height:70,
questionNo: questionRows.fieldByName('questionOrder')
});
//win.add(answerBox);
view.add(answerBox);
var btnSubmit = Ti.UI.createButton({
color: '#000',
font: { fontSize:20},
title: 'Enter',
textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER,
top: 300,
width: 300,
height: 50
});
//win.add(btnSubmit);
view.add(btnSubmit);
btnSubmit.addEventListener('click', function(e)
{
var answer1 = answerBox.value;
Ti.API.info(answer1);
//if(e.source.questionNo){
//Ti.API.info(e.rowData.value);
//}
});
...}
~~~
Any help would be greatly appreciated!
↧