easyui 简单数据库查询 和 添加

1、在项目的基础上添加:点击打开链接

2、welcome.jsp:

 

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<title>Basic Panel - jQuery EasyUI Demo</title>
	<link rel="stylesheet" type="text/css" href="./easyui/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="./easyui/themes/icon.css">
	<link rel="stylesheet" type="text/css" href="./easyui/demo/demo.css">
	<script type="text/javascript" src="./easyui/jquery.min.js"></script>
	<script type="text/javascript" src="./easyui/jquery.easyui.min.js"></script>
<title>Insert title here</title>
</head>
<body>
	<h2>Basic Layout</h2>
	<p>The layout contains north,south,west,east and center regions.</p>
	<div style="margin:20px 0;"></div>
	<div class="easyui-layout" style="width:700px;height:350px;">
		<div data-options="region:'north'" style="height:50px">
			<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add'" onclick="$('#p').panel('open')">Add</a>
		</div>
		<div data-options="region:'south',split:true" style="height:50px;"></div>
		<div data-options="region:'east',split:true" title="East" style="width:100px;"></div>
		<div data-options="region:'west',split:true" title="West" style="width:100px;"></div>
		<div data-options="region:'center',title:'Main Title',iconCls:'icon-ok'">
			<table class="easyui-datagrid"
					data-options="url:'queryEmployee.html',method:'get',border:false,singleSelect:true,fit:true,fitColumns:true">
				<thead>
					<tr>
						<th data-options="field:'id'" width="80">Id</th>
						<th data-options="field:'age'" width="100">Age</th>
						<th data-options="field:'name'" width="100">Name</th>
						<th data-options="field:'salary'" width="80">Salary</th>
						<th data-options="field:'department'" width="200">Department</th>
						<th data-options="field:'position'" width="150">Position</th>
						<th data-options="field:'phone'" width="200">Phone</th>
						<th data-options="field:'e_mail'" width="200">E-Mail</th>
					</tr>
				</thead>
			</table>
		</div>
	</div>
	<div id="p" class="easyui-window" title="Add New Employee" data-options="iconCls:'icon-save'" closed="true" style="width:500px;height:500px;padding:5px;">
		<div style="padding:10px 60px 20px 60px">
		    <form id="ff" method="post">
		    	<table cellpadding="7">
		    		<tr>
		    			<td>Age:</td>
		    			<td><input class="easyui-textbox" type="text" name="age" data-options="required:true"></input></td>
		    		</tr>
		    		<tr>
		    			<td>Name:</td>
		    			<td><input class="easyui-textbox" type="text" name="name" data-options="required:true"></input></td>
		    		</tr>
		    		<tr>
		    			<td>Salary:</td>
		    			<td><input class="easyui-textbox" type="text" name="salary" data-options="required:true"></input></td>
		    		</tr>
		    		<tr>
		    			<td>Department:</td>
		    			<td><input class="easyui-textbox" type="text" name="department" data-options="required:true"></input></td>
		    		</tr>
		    		<tr>
		    			<td>Position:</td>
		    			<td><input class="easyui-textbox" type="text" name="position" data-options="required:true"></input></td>
		    		</tr>
		    		<tr>
		    			<td>Phone:</td>
		    			<td><input class="easyui-textbox" type="text" name="phone" data-options="required:true"></input></td>
		    		</tr>
		    		<tr>
		    			<td>E-Mail:</td>
		    			<td><input class="easyui-textbox" type="text" name="e_mail" data-options="required:true"></input></td>
		    		</tr>		    		
		    	</table>
		    </form>
		    <div style="text-align:center;padding:5px">
		    	<a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()">Submit</a>
		    	<a href="javascript:void(0)" class="easyui-linkbutton" onclick="clearForm()">Clear</a>
		    </div>
	    </div>
	</div>
	<script>
		function submitForm(){
			$('#ff').form('submit',{ 
				url : 'createEmployee.html', 
				onSubmit : function() { 
					return $(this).form('validate');//对数据进行格式化 
				}, 
				success : function(data) { 
					$.messager.show({ 
						title : 'Added success!', 
						msg : data 
					}); 
				} 
			});
		}
		function clearForm(){
			$('#ff').form('clear');
		}
	</script>
</body>
</html>

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值