Results 1 to 2 of 2

Thread: How to assign ID to <input> text field and retrieve via JavaScript?

  1. #1
    Sencha User charris's Avatar
    Join Date
    Sep 2010
    Brooklyn, NY

    Question How to assign ID to <input> text field and retrieve via JavaScript?

    Hello, I'want to do something like this to create a login form and retrieve the username/password:

            var loginPanel = new Ext.Panel({
                id: 'login-window',
                xtype: 'fieldset',
                cls: 'fieldset-login',
                title: 'Welcome. Please log in to continue.',
                items: [{
    		id: 'textfield-username',
                    xtype: 'textfield',
                    placeholder: 'User ID'
                }, {
    		id: 'textfield-password',
                    xtype: 'passwordfield',
                    placeholder: 'Password'
                }, {
                    xtype: 'button',
                    cls: 'button-login',
                    handler: ...,
                    text: 'Log In',
    var username = Ext.cmp('textfield-username');
    var password = Ext.cmp('textfield-password');
    The problem is that even though I'm specifing an "id" property for the username and password text fields, the id actually gets applied to the parent <div> nodes--*not* the <input> element.

    Can anyone suggest how I can get the id to apply to the input field itself, which would make it much easier for me to retrieve the username password (e.g., var username = Ext.cmp('textfield-username); )?


  2. #2
    Sencha Premium User evant's Avatar
    Join Date
    Apr 2007
    Sydney, Australia


    Use getValue on the component, you don't need to access the field directly.
    Twitter - @evantrimboli
    Former Sencha framework engineer, available for consulting.
    As of 2017-09-22 I am not employed by Sencha, all subsequent posts are my own and do not represent Sencha in any way.

Similar Threads

  1. Selecting text in input field in panel header
    By para in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 21 Mar 2010, 10:43 PM
  2. date field text input
    By Noolaan in forum Ext GWT: Help & Discussion (1.x)
    Replies: 1
    Last Post: 14 Aug 2009, 9:34 AM
  3. How to create a Field with label and html text instead of input field?
    By ihor.ko in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 25 May 2009, 2:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts