JS small practice code_javascript skills
May 16, 2016 pm 06:59 PMThere is no html code, only JS code. The small exercises are as follows: (Learned from teacher Chen Zhiwen’s course)
<script> <BR>Ext.onReady(function(){ <BR>// Ext.Msg.alert("系统提示(thtwinj2ee)","环境配置正确!") ; <BR>var myPosition = Ext.data.Record.create( <BR>[{name:"position"}] <BR>) ;//返回一个function <BR>new Ext.Window({ <BR>title:"测试用窗口(绝不裸奔)", <BR>width:550, <BR>height:370, <BR>labelWidth:70, <BR>plain:true , <BR>layout:"form", <BR>defaults:{anchor:"95%"}, <BR>// buttonAlign:"center", <BR>items: <BR>[ <BR>{ <BR>layout:"column", <BR>baseCls:"x-plain", <BR>style:"padding:8px", <BR>items: <BR>[ <BR>{ <BR>columnWidth:.5, <BR>layout:"form", <BR>baseCls:"x-plain", <BR>labelWidth:70, <BR>defaults:{width:150}, <BR>defaultType:"textfield", <BR>items: <BR>[ <BR>{ <BR>fieldLabel:"姓名" <BR>}, <BR>{ <BR>fieldLabel:"年龄", <BR>value:23, <BR>readOnly:true <BR>}, <BR>{ <BR>xtype:"datefield", <BR>format:"Y-m-d", <BR>value:"1986-11-16", <BR>readOnly:true, <BR>fieldLabel:"出生日期", <BR>listeners: <BR>{ <BR>"blur":function(_df) <BR>{ <BR>var _age = _df.ownerCt.findByType("textfield")[1] ; <BR>_age.setValue(new Date().getFullYear() - _df.getValue().getFullYear() + 1) ; <BR>} <BR>} <BR>}, <BR>{ <BR>fieldLabel:"联系电话" <BR>}, <BR>{ <BR>fieldLabel:"手机号码" <BR>}, <BR>{ <BR>fieldLabel:"电子邮件" <BR>}, <BR>{ <BR>xtype:"combo", <BR>fieldLabel:"性别", <BR>readOnly:true, <BR>displayField:"sex", <BR>value:"男", <BR>triggerAction:"all", <BR>mode:"local", <BR>store:new Ext.data.SimpleStore <BR>( <BR>{ <BR>fields:["sex"], <BR>data:[["男"],["女"]] <BR>} <BR>) <BR>} <BR>] <BR>}, <BR>{ <BR>columnWidth:.5, <BR>layout:"form", <BR>baseCls:"x-plain", <BR>labelWidth:55, <BR>items: <BR>[ <BR>{ <BR>xtype:"textfield", <BR>width:185, <BR>height:178, <BR>fieldLabel:"个人头像", <BR>inputType:"image" <BR>} <BR>] <BR>} <BR>] <BR>}, <BR>{ <BR>layout:"form", <BR>baseCls:"x-plain", <BR>style:"padding:2px,8px,8px,8px", <BR>defaultType:"textfield", <BR>labelWidth:71, <BR>items: <BR>[ <BR>{ <BR>fieldLabel:"身份证号码", <BR>width:415 <BR>}, <BR>{ <BR>fieldLabel:"具体住址", <BR>width:415 <BR>} <BR>] <BR>}, <BR>{ <BR>layout:"column", <BR>baseCls:"x-plain", <BR>style:"padding:2px,8px,8px,8px", <BR>items: <BR>[ <BR>{ <BR>columnWidth:.4, <BR>layout:"form", <BR>baseCls:"x-plain", <BR>labelWidth:70, <BR>items: <BR>[ <BR>{ <BR>xtype:"combo", <BR>readOnly:true, <BR>mode:"local", <BR>triggerAction:"all", <BR>displayField:"position", <BR>width:100, <BR>fieldLabel:"职称", <BR>value:"初级程序员", <BR>store:new Ext.data.SimpleStore <BR>( <BR>{ <BR>fields:["position"], <BR>data:[["中级程序员"],["高级程序员"],["项目经理"]] <BR>} <BR>) <BR>} <BR>] <BR>}, <BR>{ <BR>columnWidth:.2, <BR>layout:"form", <BR>baseCls:"x-plain", <BR>items: <BR>[ <BR>{ <BR>xtype:"button", <BR>text:"添加职位", <BR>handler:function() <BR>{ <BR>var _window = this.ownerCt.ownerCt.ownerCt ; <BR>var _position = _window.findByType("combo")[1] ; <BR>Ext.Msg.prompt <BR>( <BR>"添加职位", <BR>"请输入将要添加的职位内容", <BR>function(_btn,_text) <BR>{ <BR>if(_btn == "ok") <BR>{ <BR>var _store = this.store ; <BR>_store.insert(0,new myPosition({position:_text})) ; <BR>this.setValue(_text) ; <BR>} <BR>}, _position //用来代替前面function()中的this对象 <BR>); <BR>} <BR>} <BR>] <BR>}, <BR>{ <BR>columnWidth:.2, <BR>layout:"form", <BR>baseCls:"x-plain", <BR>items: <BR>[ <BR>{ <BR>xtype:"button", <BR>text:"修改职位", <BR>handler:function() <BR>{ <BR>var _window = this.ownerCt.ownerCt.ownerCt ; <BR>var _position = _window.findByType("combo")[1] ; <BR>Ext.Msg.prompt( <BR>"修改职位(绝不裸奔)", <BR>"请输入你将要修改的内容:", <BR>function(_btn,_text) <BR>{ <BR>if(_btn == "ok") <BR>{ <BR>this.setValue(_text) ; <BR>} <BR>}, <BR>_position, <BR>false, <BR>_position.getValue() <BR>) ; <BR>} <BR>} <BR>] <BR>}, <BR>{ <BR>columnWidth:.2, <BR>layout:"form", <BR>baseCls:"x-plain", <BR>items: <BR>[ <BR>{ <BR>xtype:"button", <BR>text:"删除职位", <BR>handler:function() <BR>{ <BR>var _window = this.ownerCt.ownerCt.ownerCt ; <BR>var _position = _window.findByType("combo")[1] ; <BR>Ext.Msg.confirm <BR>( <BR>"警告(thtwinj2ee)", <BR>"你真的要删除该项内容吗?", <BR>function(_btn) <BR>{ <BR>if(_btn == "yes") <BR>{ <BR>this.store.remove(this["selectItem"]) ; <BR>if(this.store.getCount() != 0) <BR>{ <BR>this.setValue(this.store.getAt(0).get("position")) ; <BR>this["selectItem"] = this.store.getAt(0).get("position") ; <BR>} <BR>} <BR>}, <BR>_position <BR>) ; <BR>} <BR>} <BR>] <BR>} <BR>] <BR>} <BR>], <BR>listeners: <BR>{ <BR>"show":function(_window) <BR>{ <BR>_window.findByType("textfield")[5].getEl().dom.src = "02.jpg" ; <BR>} <BR>}, <BR>buttons: <BR>[ <BR>{ <BR>text:"确定" <BR>}, <BR>{ <BR>text:"取消" <BR>} <BR>] <BR>}).show() ; <BR>}) ; <BR></script>

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to practice typing with Kingsoft Typing Guide - How to practice typing with Kingsoft Typing Guide

How to use JS and Baidu Maps to implement map pan function

Essential tools for stock analysis: Learn the steps to draw candle charts with PHP and JS

Recommended: Excellent JS open source face detection and recognition project

PHP and JS Development Tips: Master the Method of Drawing Stock Candle Charts

How to create a stock candlestick chart using PHP and JS

How to use JS and Baidu Maps to implement map polygon drawing function

How to use JS and Baidu Map to implement map click event processing function
