Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-2814] TextField

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionInvalid
Resolution Date2012-08-30T23:23:07.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsiOS
Labelsn/a
Reporterprasanna
AssigneeNeeraj Gupta
Created2011-04-15T03:30:17.000+0000
Updated2012-08-30T23:23:15.000+0000

Description

Here i using five textfields are added to row in tableview with same instance of textfield how to reterive the value from the textfield

here i attached my sample code

// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');


//
var win1 = Titanium.UI.createWindow({  
    title:'Tab 1',
    backgroundColor:'red'
});
win1.open();

var data = [];

data[0] = Ti.UI.createTableViewSection({ headerView:'headerView' });
data[1] = addRow('First Name');
data[2] = addRow('Middle Name');
data[3] = addRow('Last Name');
data[4] = addRow('DOB');
data[5] = addRow('DOR');

tableView = Ti.UI.createTableView({
  data:data,
  style: Titanium.UI.iPhone.TableViewStyle.GROUPED


});

win1.add(tableView);

function addRow(labelName)
{
   row = Ti.UI.createTableViewRow({height:50});
   label = Titanium.UI.createLabel({
        font:{fontSize:13,fontFamily:'Helvetica Neue', fontWeight:'bold'},
        color: '#666',
        text: labelName,
        left: 5,
        height:'auto',
        width:'auto',
        textAlign:'left'
    });
    row.add(label);

    tf1 = Titanium.UI.createTextField({
        font:{fontSize:18,fontFamily:'Marker Felt', fontWeight:'bold'},
        color:'#888',
        height:35,
        top:10,
        right:10,
        width:190,
        hintText:labelName,
        textAlign: 'right',
        clearButtonMode: Titanium.UI.INPUT_BUTTONMODE_ALWAYS,
        borderStyle:Titanium.UI.INPUT_BORDERSTYLE_NONE
    });

    if((labelName == 'First Name') || (labelName == 'Last Name'))
    {
      tf1.autocorrect = false;
    }
     if((labelName == 'DOB') || (labelName == 'DOR'))
    {
         //tf1.enabled=false;
         tf1.editable=false;
    }
    row.add(tf1);
    row.selectionStyle = Ti.UI.iPhone.TableViewCellSelectionStyle.NONE;
    return row;
}





var addToLocalDB = Titanium.UI.createButton({
    width:280,
    height:66,
    top:300
});
win1.add(addToLocalDB);

addToLocalDB.addEventListener('click',function(e)
{    
    alert(label.text);
    if(label.text=='DOB')
    {
        alert(tf1.value);
    }

});

Comments

  1. Paul Dowsett 2012-05-04

    This is a question rather than a bug. Please kindly direct questions about how to develop with Titanium to the [Q&A](http://developer.appcelerator.com/questions/created) or Helpdesk. Thank you. Closing as invalid.
  2. Neha Chhabra 2012-08-30

    Closing. Bug marked as invalid as per Paul Dowsett

JSON Source