【问题标题】:how to get the form values when i click on submit in sencha touch当我在 sencha touch 中单击提交时如何获取表单值
【发布时间】:2011-10-01 00:03:23
【问题描述】:

我是 sencha touch 的新手,我创建了一个登录表单,它接受用户 ID 和密码以及一个登录按钮,所以当我点击登录按钮时,我应该得到用户 ID 值作为警报。代码是,

Ext.setup ({
onReady: function () {

    var myform=new Ext.form.FormPanel({
    id:'form',
    fullscreen:true,
    standardSubmit:true,
    dockedItems:[{
    Dock:'top',
    xtype:'toolbar',
    height:40,
    title:'Tool Bar',
    id:'login',
    }
    ],
    items:[{
 xtype:'textfield',
 name:'id',

 width:'50%',
 align:'center',
 label:'User Id'
 },
 {
 xtype:'textfield',
 name:'pwd',
 id:'pwd',
 width:'50%',
 align:'center',
 label:'Password'
 },

 {
  xtype:'button',
  ui:'round',
  width:'50%',
  text:'Login',
  align:'center',
  handler:function()
  {
    gettingvalues();/* var fields = form.getValues();
    console.log(fields['name']); */

  }
 }
 ],

    });

    gettingvalues=function()
    {
      var fields=myform.getValues();
      Ext.Msg.alert(fields['id'].getValue()); 
    }


}

});

但是我没有得到任何警报的价值,我必须做什么。 之后,我想将这些值发送到需要 id 和密码的本地服务器,格式为... oururl?action=login&id=xyz&pwd=xyz, 在这它将接受并返回响应,所以我必须写什么, 请尽快告诉我。 提前致谢。

【问题讨论】:

    标签: sencha-touch


    【解决方案1】:

    您可以通过其名称属性获取表单值,如下所示:

    {
      xtype:'button',
      ui:'round',
      width:'50%',
      text:'Login',
      align:'center',
      handler:function()
      {
         var form = myForm.getValues();
         console.log('Form Object: ' + form);
         console.log('User ID Field: ' + form.id);
         console.log('Password Field: ' + form.pwd);         
      }
    }
    

    【讨论】:

      【解决方案2】:

      你试过了吗:

      var fields=myform.getValues();
      Ext.Msg.alert(fields['id']);
      

      您是否收到任何 javascript 错误?

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-03-29
        • 2011-05-17
        • 1970-01-01
        • 1970-01-01
        • 2012-05-21
        • 2012-07-09
        • 1970-01-01
        相关资源
        最近更新 更多