?
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Checkbox TreePanel</title> <link rel="stylesheet" type="text/css" href="/ext/docs/resources/ext-all.css" /> <script type="text/javascript" src="/ext/docs/resources/ext-base.js"></script> <script type="text/javascript" src="/ext/docs/resources/ext-all.js"></script> </head> <body> </body>
?
?
?
<script type="text/javascript">
Ext.onReady(function(){
Ext.QuickTips.init();
var form1 = new Ext.form.FormPanel({
baseCls : 'x-plain',
labelWidth : 70,
fileUpload : true,
defaultType : 'textfield',
items : [{
xtype : 'textfield',
fieldLabel : '姓名',
name : 'username',
id : 'username',
allowBlank:false,
blankText : 'you must input sth .',
anchor : '100%' // anchor width by percentage
}]
});
var win = new Ext.Window({
title : '表单提交',
width : 400,
height : 100,
minWidth : 300,
minHeight : 100,
layout : 'fit',
plain : true,
bodyStyle : 'padding:5px;',
buttonAlign : 'center',
items : form1,
buttons : [{
text : '普通方式提交',//这种方式 后台页面要跳转 ,就和平时jsp页面上的form一样
handler : function() {
if ( form1.form.isValid() ) {
var form = form1.getForm().getEl().dom;
form.action = '/aicpa/aicpaTest_uploadFile.action'
//form.method = 'GET';//GET、POST
form.submit();
}
}
},{
text : 'Ajax方式提交',
handler : function() {
if ( form1.form.isValid() ) {
form1.getForm().submit({
url : '/aicpa/aicpaTest_uploadFile.action',
method : 'POST',
waitTitle:'提示',
waitMsg:"提交中。。。。。",
success : function(form, action) { //返回值 {success:true}
Ext.Msg.alert('Message', action.result.success); //服务端所有的字符串
alert(action.response.responseText);
//win.close();
},
failure : function(form, action) {
Ext.Msg.alert('Error', action.result.errormsg );
alert(action.result.errormsg);
}
})
}
},
},{
text : 'Connect方式', //数据返回格式 随意
handler : function() {
if ( form1.form.isValid() ) {
var conn = new Ext.data.Connection();
conn.request({
url:'/aicpa/aicpaTest_uploadFile.action',
method:'POST',
params:form1.form.getValues(),
success:function(response , opts ){
alert(response.responseText );
}
});
}
},
},{
text : 'Ajax方式', //数据返回格式 随意
handler : function() {
if(form1.form.isValid() ) {
Ext.Ajax.request({
url:'/aicpa/aicpaTest_uploadFile.action',
method:'post',
//jsonData://指定需要发送给服务器端的JSON数据。如果指定了该属性则其它的地方设置的要发送的参数值将无效。
//xmlData://指定用于发送给服务器的xml文档,如果指定了该属性则其它地方设置的参数将无效。
params:form1.form.getValues(),
callback:function(options,success,response ){
if(success){
Ext.Msg.alert('success',response.responseText);
}
}
});
}
},
}, {
text : '关闭',
handler : function() {
win.close();
}
}]
});
win.show();
});
</script>
?
