ExtJs学习笔记——登录窗口的使用

这里是引用
话不多说上代码,代码中都添加了你们所需要的只是有啥不懂的可以直接留言。
我这里才用的是6.2的框架

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>表单提交</title>
<link rel="stylesheet" type="text/css"
	href="extjs6/build/classic/theme-crisp/resources/theme-crisp-all.css" />
 <link rel="stylesheet" type="text/css"
	href="extjs6/build/classic/theme-crisp/resources/theme-crisp-all-debug.css" />
<script src="extjs6/build/ext-all.js"></script>
<script src="extjs6/build/ext-debug.js"></script>
<script src="extjs6/build/classic/locale/locale-zh_CN.js"></script> 
<script src="extjs6/ext-bootstrap.js"></script>
<script type="text/javascript " src="js/jquery-3.3.1.js"></script>
<script type="text/javascript">

Ext.onReady(function(){  
	var f=new Ext.form.FormPanel({
		url:"${pageContext.request.contextPath}/StudentServlet?method=login", 
		method:"post",
		baseParams:{extra:"attach",id:100},   //动态赋值
		title:"欢迎登陆",
		width:300,
		height:150,
		bodyStyle:"padding:2px",
		labelAlign:"right",                   //label的对齐方式
		frame:true,                           //为true 时可以为panel 添加背景色
		items:[
			new Ext.form.TextField({
				name:"userName",
				allowBlank:false,            //不允许为空
				fieldLabel:"用户名",           
				labelAlign:"right"
			}),{
				name:"password",
				xtype:"textfield",
				inputType:"password",        //input的type 属性
				fieldLabel:"密码",
				labelAlign:"right",
				allowBlank:false
			}
		],
		buttons:[{
			text:"确定",
			handler:function(){
				var userName=f.getForm().findField("userName").getValue();  //获取name 的值
				var password=f.getForm().findField("password").getValue();  //获取password
				Ext.Msg.alert("","用户名:"+userName+"<br>密码"+password);
				f.getForm().submit({ //提交表单 并返回成功函数
					success:function(f,action){
						Ext.Msg.alert("成功","恭喜表单提交成功");
						Ext.Msg.alert(action.result);
						window.location.href="demo.jsp";
					},failure:function(f,action){
						Ext.Msg.alert("失败","表单提交失败");
						Ext.Msg.alert("失败"+action.result);
					}
				})
			}
		},{
			text:"重置",
			handler:function(){
				f.getForm().reset();
			}
		}]
		
	})
	f.render("a");
});

</script>
</head>
<body>
<table align='center'  >      <!--主要用于居中属性 -->
   	<td>
<div  id="a"></div>
    </td>
</table>
</body>
</html>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值