ext 以傳統的表單提交

 Ext.onReady(function()
{
    var fp = new Ext.FormPanel({
        renderTo: 'hello',
//        fileUpload: true,文件上傳
        width: 500,
        frame: true,
        standardSubmit:true,//傳統的表單提交
        title: 'File Upload Form',
        autoHeight: true,
//        bodyStyle: 'padding: 10px 10px 0 10px;',
        labelWidth: 50,
        defaults: {
            anchor: '95%',
            allowBlank: false,
            msgTarget: 'side'
        },
        items: [{
            name:'label_fileUpload',
            xtype: 'textfield',
            fieldLabel: 'Name'
        },{
            xtype: 'fileuploadfield',
            id: 'form-file',
            emptyText: 'Select an file',
            fieldLabel: 'Photo',
            name: 'file_path',
            buttonText: '',
            buttonCfg: {
                iconCls: 'upload-icon'
            }
//        ,
//            autoCreate : {  
//                tag : "input",  
//                type : "file",  
//                size : "20",  
//                autocomplete : "off",  
//                onChange : "browseImages(this.value);"  
//            }
        
        }],
        buttons: [{
            text: 'Save',
            handler:formSubmit//設置Save函數
//            handler: function(){    
//                if(fp.getForm().isValid()){
//                    fp.getForm().submit({
//                        url: '../File_upload',
//                        waitMsg: 'Uploading your file',
//                        success: function(form, action){
//                            alert('success');
//                        }
//                        ,failure:function(form,action){
//                            alert('failure');
//                        }
//                    });
//                }
//            }
        },{
            text: 'Reset',
            handler: function(){
                fp.getForm().reset();
            }
        }]
    });
    function formSubmit(){
        fp.getForm().getEl().dom.action="../File_upload";
        fp.getForm().submit();
    }

});

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章