Heim > Web-Frontend > js-Tutorial > Hauptteil

JS之小练习代码_javascript技巧

WBOY
Freigeben: 2016-05-16 18:59:53
Original
1003 Leute haben es durchsucht

没有html代码,只有JS代码,小练习内容如下:(从陈治文老师的课程中学到)
<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>

Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage