0

I Am using Extjs 4 , I want Type the Value automatically in my Login Page ?

My code is below I am setting the text for UserName and Password

When I try to retrieve in Login Page in GUI the UserName Value is Not Filled With Mark

Instead Both Mark and Jessey is filling and AutoTyped in Password

How To Actually set the Code in the respective Field

Login.js

Ext.onReady(function(){

        Ext.QuickTips.init();


 items: [
               {
                                        xtype: 'textfield',
                                         fieldLabel: 'UserName',
                                        name: 'j_username',
                                        id: 'lf.txt.username', //Trying to pass Value for this id in GUI as Mark
                },

                {
                                        xtype: 'textfield',
                                        inputType: 'password',
                                        fieldLabel: 'Password',
                                        name: 'j_password',
                                        id: 'lf.txt.password',//Trying to pass Value for this id in GUI as Jessey When i Launch Code 
                 }
 ]
}
}

When I try to use the above value in my Login.Html page

Like Below INdex.js

{
 var userName = Ext.getCmp('lf.txt.username');
       alert(userName);
       // alert(lf.txt.password);  // It is Gettin UserName as MArk 
        t.diag(userName.title);
        t.type(userName, 'Mark');

        var password = Ext.getCmp('lf.txt.password');
        alert(password); // It is Gettin password as Jessey Correctly 
        t.diag(password.title);
        t.type(password, 'Jessey');
}

But I am Able to print Both UserName and Password in Password Field only!

I am Able to print the Both Mark And Jessey in Password Field But Not the UserName?

Can anyone Tell me How to Set The Value for UserName In The .js PAge?

Let Me know how to pass the Username and password value to respective field?

CBroe
  • 82,033
  • 9
  • 81
  • 132
Bala_Tech
  • 13
  • 1
  • 6

1 Answers1

0

You get component itself with Ext.getCmp function. You should get the input value with Ext.getCmp(cmpId).getValue(). By the way I couldn't see any container for your input fields? I don't think this code works properly. If you're working on inputs, it's recommended to use form panel; then get inputs using form panel's function.

A working sample should be something like this:

var form = Ext.create('Ext.form.Panel', {
    title : 'A title',
    items : [{
       xtype : 'textfield',
       name  : 'input1',
       fieldLabel: 'Label1'
    }, {
       xtype : 'textfield',
       name  : 'input2',
       fieldLabel: 'Label2'
    }]
});

form.getForm().findField('input1').getValue();
talha06
  • 5,286
  • 16
  • 75
  • 127
  • Thanks above Code works fine , i am able to get the components correctly But Could you tell me how to just check the check box Ext.getCmp(cmpId).getValue() But can you tell me how to check the CheckBox True ? Thanks in Advance – Bala_Tech Mar 27 '13 at 09:51
  • it's same with textfields; you can use `getValue()` method. It turns a `boolean` value, checked means `true`. – talha06 Mar 27 '13 at 11:57
  • glad to help you. then you can mark this question as 'answered'. – talha06 Apr 02 '13 at 19:56