title: Titanium Pass Textfield Value to New Window
body: <p>I am attempting to take the value of a textfield and pass it to a new window (Javascript file) using Ti.App.fireEvent (<a href="http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.App-method-fireEvent" rel="nofollow">http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.App-method-fireEvent</a>) so that I can eventually insert it into a database when a button is pressed... So far I have a variable that stores the value of the textfield called usernameValue. This will then be sent to an http parameter value. There has to be something simple that I'm missing.  Let me know if more information is needed to make this question more clear.</p>
  
  <p>TexField where data originally comes from:</p>
  
  <pre><code>var username = Titanium.UI.createTextField({
      //color : '#ffffff',
      top : 10,
      width : 300,
      height : 45,
      hintText : 'Username',
      keyboardType : Titanium.UI.KEYBOARD_DEFAULT,
      returnKeyType : Titanium.UI.RETURNKEY_DEFAULT,
      borderStyle : Titanium.UI.INPUT_BORDERSTYLE_ROUNDED,
      clearButtonMode: Titanium.UI.INPUT_BUTTONMODE_ONFOCUS
  });
  </code></pre>
  
  <p>Needs passed from login.js: </p>
  
  <pre><code>//FireEvent parameter passing!
  var usernameValue = username.value;
  
  Ti.App.addEventListener('sendDataToScreen', function()
  {
      Ti.App.fireEvent('app:populateUsername', usernameValue);
  });
  </code></pre>
  
  <p>IM.js retrieval: </p>
  
  <pre><code>//FireEvent Paremeter Passing!
  Ti.App.fireEvent('app:populateUsername', usernameValue);
  </code></pre>
  
  <p>New Window (in case this helps):</p>
  
  <pre><code>//if logged in, open new window!
          var IM = Ti.UI.createWindow({
              url : 'IM.js',
              navBarHidden : false,
              // fullscreen:false
  
          });
          IM.open();
  </code></pre>
  
  <p>Button parameter passing where used:</p>
  
  <pre><code>//posting of IM onclick to database!!
  postBtn.addEventListener('click', function(e) {
  
      if (chatBox.value != '') {
  
          createReq.open("POST", "http://***.php");
          var params = {
  
              post : chatBox.value,
              user : _data.username
          };
          createReq.send(params);
  
          //tap to repload and clear
          var rd = [];
          tableview.data = rd;
          setData();
  
      } else {
          var blankAlert = Titanium.UI.createAlertDialog({
              title : 'Posting Error',
              message : 'Post cannot be empty',
              buttonNames : ['OK']
          });
          blankAlert.show();
      }
  });
  </code></pre>