1. #1
    Sencha User
    Join Date
    Jan 2008
    Posts
    66
    Vote Rating
    0
    mnask is on a distinguished road

      0  

    Default i want Enter key submit my form

    i want Enter key submit my form


    Hi There

    i need your help plz ...
    i want in my form when i press on Enter Key i submit my form


    this is my code

    loginForm = function() {

    return {

    init : function(){

    Ext.form.Field.prototype.msgTarget = 'under';

    var username = new Ext.form.TextField({
    allowBlank:false,
    applyTo:'username'
    });

    var pass = new Ext.form.TextField({
    allowBlank:false,
    inputType: 'password',
    applyTo:'password'
    });

    var converted = new Ext.form.ComboBox({
    editable: false,
    triggerAction: 'all',
    transform:'lang_id',
    width:135,

    forceSelection:true
    });

    var code = new Ext.form.TextField({
    allowBlank:false,
    applyTo:'code'
    });

    var loginbutton = new Ext.Button({
    text:'login',
    applyTo:'button_login',
    handler:this.send
    });
    var formPanel = Ext.get("formPanel");
    formPanel.center()

    },

    send: function () {
    //Seralizamos el formulario
    var params=Ext.Ajax.serializeForm('form1');
    var url = 'auth.php';
    alert(params);
    Ext.Ajax.request(
    {
    url:url,
    params: params,
    method:'post',
    failure: loginForm.onfailure,
    callback: function(opts,suss,resp) { loginForm.onSucces(resp); }
    }
    );
    },


    onSucces: function (response) {
    var result = Ext.decode(response.responseText);
    alert(result.status);
    alert(result.value);
    switch(result.status) {
    case 'true': window.location="./main.php";
    break;
    case 'false': Ext.getDom('systemMsgBody').innerHTML=result.value ;
    Ext.getDom('systemMsg').style.display='';
    this.setCode(result);
    }
    },

    onfailure: function () {
    //Ext.MessageBox.alert('Message', 'Failed to connect to the server');
    Ext.getDom('systemMsgBody').innerHTML='Failed to connect to the server';
    Ext.getDom('systemMsg').style.display='';
    },

    setCode: function(rs){
    if (rs.cd == 1) {
    Ext.getDom('codeHld').style.display='';
    Ext.getDom('ic').src='../ebrokerage_lib/showRandStrImage.php';
    }
    }

    };

    }();

    Ext.EventManager.onDocumentReady(loginForm.init, loginForm, true);

    can u help me plz

    thanks
    Edit/Delete Message

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    91
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    Have a look at the Ext.KeyNav docs.

  3. #3
    Sencha User
    Join Date
    Jan 2008
    Posts
    66
    Vote Rating
    0
    mnask is on a distinguished road

      0  

    Default


    SORRY ,I DONT USE EXT FOR LONG TIME , REALLY I DONT KNOW HOW TO USE Ext.KeyNav IN MY FORM
    COULD U HELP ME PLZ


    THANKS

  4. #4
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    91
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    Example:

    Code:
    var nav = new Ext.KeyNav(form.getForm().getEl(), {
      'enter': function(e) {
        this.getForm().submit();
      },
      'scope': form
    });

  5. #5
    Sencha User
    Join Date
    Jan 2008
    Posts
    66
    Vote Rating
    0
    mnask is on a distinguished road

      0  

    Default


    Thanks , but this code dose not work
    what i have to do ?

  6. #6
    Ext User
    Join Date
    Mar 2008
    Posts
    10
    Vote Rating
    0
    alslp is on a distinguished road

      0  

    Default


    I met the same problem.
    The code doesn't work for me either.
    The error message is as follows.

    Code:
    uncaught exception: [Exception... "Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIXMLHttpRequest.open]" nsresult: "0x80070057 (NS_ERROR_ILLEGAL_VALUE)" location: "JS frame :: http://127.0.0.1/lib/ext/adapter/ext/ext-base.js :: anonymous :: line 10" data: no]
    Anyone can help?

  7. #7
    Ext User
    Join Date
    Jul 2007
    Posts
    3,128
    Vote Rating
    1
    devnull is an unknown quantity at this point

      0  

    Default


    It seems to be indicating that you have an invalid url property on your form or you are violating the same origin security restriction on ajax requests. either way its impossible to say without seeing the whole form constructor code.

  8. #8
    Sencha User
    Join Date
    Oct 2007
    Location
    Berlin, Germany
    Posts
    891
    Vote Rating
    9
    wm003 will become famous soon enough

      0  

    Default


    You can specify the specialkey listener for the formfield that you want the enterkey to submit the form

    apply this config to the formfield which should submit the form when pressing ENTER:

    PHP Code:
    listeners:{
                    
    specialkey:function(f,o){
                        if(
    o.getKey()==13){
                            
    f.submit();
                        }
                    }
                }, 

  9. #9
    Ext User doogii's Avatar
    Join Date
    Nov 2007
    Posts
    5
    Vote Rating
    0
    doogii is on a distinguished road

      0  

    Default


    "f" is form id?

  10. #10
    Sencha - Community Support Team mystix's Avatar
    Join Date
    Mar 2007
    Location
    Singapore
    Posts
    6,236
    Vote Rating
    5
    mystix will become famous soon enough

      0  

    Default


    emphasis added:
    Quote Originally Posted by wm003 View Post
    You can specify the specialkey listener for the formfield that you want the enterkey to submit the form

    apply this config to the formfield which should submit the form when pressing ENTER:
    so no. "f" is not the form.id

    see http://extjs.com/docs/?class=Ext.for...ber=specialkey for more details.