⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xml-form.js

📁 着重用css实现页面显示功能,实现简单数据库连接,是很好的入门教程
💻 JS
字号:
/*
 * Ext JS Library 1.1.1
 * Copyright(c) 2006-2007, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://www.extjs.com/license
 */

Ext.onReady(function(){    Ext.QuickTips.init();    // turn on validation errors beside the field globally    Ext.form.Field.prototype.msgTarget = 'side';    var fs = new Ext.form.Form({        labelAlign: 'right',        labelWidth: 75,        waitMsgTarget: 'box-bd',        // configure how to read the XML Data        reader : new Ext.data.XmlReader({            record : 'contact',            success: '@success'        }, [            {name: 'first', mapping:'name/first'}, // custom mapping            {name: 'last', mapping:'name/last'},            'company', 'email', 'state',            {name: 'dob', type:'date', dateFormat:'m/d/Y'} // custom data types        ]),        // reusable eror reader class defined at the end of this file        errorReader: new Ext.form.XmlErrorReader()    });    fs.fieldset(        {legend:'Contact Information'},        new Ext.form.TextField({            fieldLabel: 'First Name',            name: 'first',            width:190        }),        new Ext.form.TextField({            fieldLabel: 'Last Name',            name: 'last',            width:190        }),        new Ext.form.TextField({            fieldLabel: 'Company',            name: 'company',            width:190        }),        new Ext.form.TextField({            fieldLabel: 'Email',            name: 'email',            vtype:'email',            width:190        }),        new Ext.form.ComboBox({            fieldLabel: 'State',            hiddenName:'state',            store: new Ext.data.SimpleStore({                fields: ['abbr', 'state'],                data : Ext.exampledata.states // from states.js            }),            valueField:'abbr',            displayField:'state',            typeAhead: true,            mode: 'local',            triggerAction: 'all',            emptyText:'Select a state...',            selectOnFocus:true,            width:190        }),        new Ext.form.DateField({            fieldLabel: 'Date of Birth',            name: 'dob',            width:190,            allowBlank:false        })    );    // simple button add    fs.addButton('Load', function(){        fs.load({url:'xml-form.xml', waitMsg:'Loading'});    });    // explicit add    var submit = fs.addButton({        text: 'Submit',        disabled:true,        handler: function(){            fs.submit({url:'xml-errors.xml', waitMsg:'Saving Data...'});        }    });    fs.render('form-ct');    fs.on({        actioncomplete: function(form, action){            if(action.type == 'load'){                submit.enable();            }        }    });});// A reusable error reader class for XML formsExt.form.XmlErrorReader = function(){    Ext.form.XmlErrorReader.superclass.constructor.call(this, {            record : 'field',            success: '@success'        }, [            'id', 'msg'        ]    );};Ext.extend(Ext.form.XmlErrorReader, Ext.data.XmlReader);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -