Quantcast
Viewing all articles
Browse latest Browse all 8068

how to pass textfield value from one view to another on button click

Hi I am able to navigate one window to another , now i need to pass textfield value from one view to another here is my code First view

//FirstView Component Constructor
function FirstView() {
    //create object instance, a parasitic subclass of Observable
    var self = Ti.UI.createView({
        layout:"vertical"
    });
 
 
        var self1 = Ti.UI.createView({
        layout:"horizontal",
        top:20,
        height:Ti.UI.SIZE
    });
 
 
 
        var self2 = Ti.UI.createView({
        layout:"horizontal",
        top:10,
        height:Ti.UI.SIZE
    });
 
 
 
    //label using localization-ready strings from <app dir>/i18n/en/strings.xml
 
        var nameLabel=Ti.UI.createLabel({
 
        text:"Name",
 
        left:15,
        width:100,
        height:35
    });
 
 
 
 
    var nameTextField=Ti.UI.createTextField({
 
    height:35,
    width:140,
    borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED       
    });
 
        self1.add(nameLabel);
        self1.add(nameTextField);
            self.add(self1);
 
    var passwordLabel=Ti.UI.createLabel({
 
        text:"Password",
 
        left:15,
        width:100,
        height:35
    });
 
 
 
 
    var passwordTextField=Ti.UI.createTextField({
 
    height:35,
    width:140,
    passwordMask:true,
    borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED       
    });
 
 
    var loginButton =Ti.UI.createButton({
 
        title:"LOGIN",
        top: 120,
        width:200,
        height:40
 
    });
 
 
    loginButton.addEventListener('click',function(e){
        passwordTextField.blur();
        nameTextField.blur();
        alert(nameTextField.value);
 
          var window1 = require('ui/common/SecondView');
      var newWindow = new window1();
    newWindow.open();
    });
 
    self2.add(passwordLabel);
    self2.add(passwordTextField);
    self.backgroundImage="ui/images/a.png";
 
    self.add(self2);
    self.add(loginButton);
 
    self.addEventListener('click',function(e){
 
        console.log(e.source);
        if(e.source != '[object TiUITextField]'){
            //alert("window click");
        passwordTextField.blur();
        nameTextField.blur();
 
}
 
    });
    return self;
}
 
module.exports = FirstView;
Second window
//FirstView Component Constructor
function SecondView2() {
    //create object instance, a parasitic subclass of Observable
 
    var wn = Ti.UI.createWindow({
        backgroundColor:'#ffffff'
    });
    var self = Ti.UI.createView({
        layout:"vertical"
    });
 
 
        var nameText=Ti.UI.createLabel({
            text:"Second view",
        });
 
        self.add(nameText);
        wn.add(self);
    return wn;
}
 
module.exports = SecondView2;

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>