资源描述:
《ext_form表单提交》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、ExtJs表单提交Ext.QuickTips.init();Ext.BLANK_IMAGE_URL='js/ext3/resources/s.gif';Ext.onReady(function(){varloginForm=newExt.FormPanel({frame:true,method:'POST',border:false,formId:'form1',name:'form1',//onSubmit:Ext.emptyFn,//submit:function(){//this.getEl().dom.action='co
2、mmon/ajax/login.jsp';//连接到服务器的url地址//this.getEl().dom.submit();//alert(this.getEl().dom.elements.length);//},defaults:{xtype:'textfield',anchor:'90%'},items:[{name:'username',id:'username',fieldLabel:'用户名'},{name:'password',inputType:'password',fieldLabel:'密码'},{name:
3、'code',fieldLabel:'验证码',anchor:'50%'}],buttons:[{text:'登录',type:'submit',//第三种方式handler:function(){Ext.Ajax.request({url:'common/ajax/login.jsp',method:'POST',params:{'username':Ext.get("username").dom.value},success:function(form,action){vartext=eval("("+form.respons
4、eText+")");alert('--------------2='+text.msg);},failure:function(){alert('--------------1');}})}//第二种方式/*handler:function(){loginForm.form.doAction('submit',{url:'/ext/common/ajax/login.jsp',method:'POST',params:'',success:function(form,action){//alert(action.result);
5、if(action.result.msg=='ok'){//document.location='index.html';Ext.Msg.alert('成功',action.result.msg);}else{Ext.Msg.alert('登陆错误',action.result.msg);}},failure:function(form,action){Ext.Msg.alert('警告','用户名或密码错误!');}})}*///第一种方式//handler:function(){//loginForm.form.submit(
6、);//}},{text:'取消',handler:function(){loginForm.form.reset();}}]});varwin=newExt.Window({title:'window',width:400,frame:true,border:false,modal:true,resizable:false,items:loginForm});win.show();});1、正常form提交这种方式需要在FormPanel对象中增加属性onSubmit:Ext.emptyFn,submit:function(){
7、this.getEl().dom.action='common/ajax/login.jsp';//连接到服务器的url地址this.getEl().dom.submit();alert(this.getEl().dom.elements.length);},提交按钮:handler:function(){loginForm.form.submit();}2、默认提交方式(Ajax)默认的提交方式:handler:function(){loginForm.form.doAction('submit',{url:'/ext/comm
8、on/ajax/login.jsp',method:'POST',params:'',success:function(form,action){//alert(action.result);if(action.result.msg=='ok'){