姓名查询 年龄排序 添加用户 删除
来源:互联网 发布:android wear源码下载 编辑:程序博客网 时间:2024/04/29 13:05
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
table {
margin-top: 20px;
}
table tr:nth-child(even) {
background: #eeeeee;
}
table tr:hover {
background: #41C7DB;
}
#button {
margin-top: 20px;
}
</style>
<script type="text/javascript" src="js/angular.js"></script>
<script type="text/javascript">
var app = angular.module("myapp", []);
app.controller("myctrl", function($scope) {
$scope.users = [{
"name": "张三",
"age": 45,
"pinyin": "zhang san",
"position": "总经理",
"operation": "删除"
}, {
"name": "李四",
"age": 43,
"pinyin": "li si",
"position": "设计师",
"operation": "删除"
}, {
"name": "王五",
"age": 40,
"pinyin": "wang wu",
"position": "工程师",
"operation": "删除"
}, {
"name": "赵六",
"age": 33,
"pinyin": "zhao liu",
"position": "工程师",
"operation": "删除"
}, {
"name": "周七",
"age": 32,
"pinyin": "zhou qi",
"position": "人事经理",
"operation": "删除"
}];
$scope.cha = function() {
var flag = false;
$scope.a = "";
reg = /法轮功/g;
for(index in $scope.users) {
if($scope.chaname == $scope.users[index].name) {
flag = true;
}
}
if($scope.chaname == "" || $scope.chaname == null) {
alert("请输入姓名");
} else if(flag) {
alert("搜到");
$scope.a = $scope.chaname;
} else if(reg.test($scope.chaname)) {
alert("敏感字");
} else {
alert("搜不到");
$scope.a = null;
}
};
$scope.tianjia = false;
$scope.add = function() {
$scope.tianjia = true;
};
$scope.newname = "";
$scope.newage = "";
$scope.newpinyin = "";
$scope.newposition = "";
var flag1 = flag2 = flag3 = flag4 = false;
$scope.bao = function() {
reg = /[0-9]/;
if($scope.newname == "" || $scope.newname == null) {
alert("姓名不能为空");
flag1 = false;
} else {
flag1 = true;
}
if($scope.newage == "" || $scope.newage == null) {
alert("年龄不能为空");
flag2 = false;
}
if(!reg.test($scope.newage)) {
alert("年龄格式错误");
flag2 = false;
} else {
flag2 = true;
}
if($scope.newpinyin == "" || $scope.newpinyin == null) {
alert("拼音不能为空");
flag3 = false;
} else {
flag3 = true;
}
if($scope.newposition == "" || $scope.newposition == null) {
alert("职位不能为空");
flag4 = false;
} else {
flag4 = true;
}
if(flag1 && flag2 && flag3 && flag4) {
var newuser = {
"name": $scope.newname,
"age": parseInt($scope.newage),
"pinyin": $scope.newpinyin,
"position": $scope.newposition,
}
$scope.users.push(newuser);
}
};
</script>
</head>
<body ng-app="myapp" ng-controller="myctrl">
<center>
<h3>用户列表</h3> 姓名查询条件
<input type="text" ng-model="chaname" />
<select ng-model="agea">
<option value="">-选择排序-</option>
<option value="-age">按年龄倒序</option>
<option value="age">按年龄正序</option>
</select>
<table border="1px soild black" cellspacing="0" cellpadding="10">
<tr style="background: #999999;">
<th>姓名</th>
<th>年龄</th>
<th>拼音</th>
<th>职位</th>
<th>操作</th>
</tr>
<tr ng-repeat="u in users | orderBy:agea">
<td>{{u.name}}</td>
<td>{{u.age}}</td>
<td>{{u.pinyin}}</td>
<td>{{u.position}}</td>
<td><button style="cursor: pointer;background: none;border: none;" ng-click="del(u.name)">删除</button></td>
</tr>
</table>
<button ng-click="cha()" id="button">查询</button>
<button ng-click="add()" id="button">添加用户</button>
<fieldset style="width: 400px;" ng-show="tianjia">
<legend>添加用户信息</legend>
姓名 <input type="text" ng-model="newname" /><br /><br /> 年龄 <input type="text" ng-model="newage" /><br /><br /> 拼音 <input type="text" ng-model="newpinyin" /><br /><br /> 职位 <input type="text" ng-model="newposition" /><br /><br />
<button ng-click="bao()">保存</button>
</fieldset>
</center>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
table {
margin-top: 20px;
}
table tr:nth-child(even) {
background: #eeeeee;
}
table tr:hover {
background: #41C7DB;
}
#button {
margin-top: 20px;
}
</style>
<script type="text/javascript" src="js/angular.js"></script>
<script type="text/javascript">
var app = angular.module("myapp", []);
app.controller("myctrl", function($scope) {
$scope.users = [{
"name": "张三",
"age": 45,
"pinyin": "zhang san",
"position": "总经理",
"operation": "删除"
}, {
"name": "李四",
"age": 43,
"pinyin": "li si",
"position": "设计师",
"operation": "删除"
}, {
"name": "王五",
"age": 40,
"pinyin": "wang wu",
"position": "工程师",
"operation": "删除"
}, {
"name": "赵六",
"age": 33,
"pinyin": "zhao liu",
"position": "工程师",
"operation": "删除"
}, {
"name": "周七",
"age": 32,
"pinyin": "zhou qi",
"position": "人事经理",
"operation": "删除"
}];
$scope.cha = function() {
var flag = false;
$scope.a = "";
reg = /法轮功/g;
for(index in $scope.users) {
if($scope.chaname == $scope.users[index].name) {
flag = true;
}
}
if($scope.chaname == "" || $scope.chaname == null) {
alert("请输入姓名");
} else if(flag) {
alert("搜到");
$scope.a = $scope.chaname;
} else if(reg.test($scope.chaname)) {
alert("敏感字");
} else {
alert("搜不到");
$scope.a = null;
}
};
$scope.tianjia = false;
$scope.add = function() {
$scope.tianjia = true;
};
$scope.newname = "";
$scope.newage = "";
$scope.newpinyin = "";
$scope.newposition = "";
var flag1 = flag2 = flag3 = flag4 = false;
$scope.bao = function() {
reg = /[0-9]/;
if($scope.newname == "" || $scope.newname == null) {
alert("姓名不能为空");
flag1 = false;
} else {
flag1 = true;
}
if($scope.newage == "" || $scope.newage == null) {
alert("年龄不能为空");
flag2 = false;
}
if(!reg.test($scope.newage)) {
alert("年龄格式错误");
flag2 = false;
} else {
flag2 = true;
}
if($scope.newpinyin == "" || $scope.newpinyin == null) {
alert("拼音不能为空");
flag3 = false;
} else {
flag3 = true;
}
if($scope.newposition == "" || $scope.newposition == null) {
alert("职位不能为空");
flag4 = false;
} else {
flag4 = true;
}
if(flag1 && flag2 && flag3 && flag4) {
var newuser = {
"name": $scope.newname,
"age": parseInt($scope.newage),
"pinyin": $scope.newpinyin,
"position": $scope.newposition,
}
$scope.users.push(newuser);
}
};
$scope.del = function(name) {
if(window.confirm("是否删除")) {
for(index in $scope.users) {
if(name == $scope.users[index].name) {
$scope.users.splice(index, 1);
}
}
}
}
</script>
</head>
<body ng-app="myapp" ng-controller="myctrl">
<center>
<h3>用户列表</h3> 姓名查询条件
<input type="text" ng-model="chaname" />
<select ng-model="agea">
<option value="">-选择排序-</option>
<option value="-age">按年龄倒序</option>
<option value="age">按年龄正序</option>
</select>
<table border="1px soild black" cellspacing="0" cellpadding="10">
<tr style="background: #999999;">
<th>姓名</th>
<th>年龄</th>
<th>拼音</th>
<th>职位</th>
<th>操作</th>
</tr>
<tr ng-repeat="u in users | orderBy:agea">
<td>{{u.name}}</td>
<td>{{u.age}}</td>
<td>{{u.pinyin}}</td>
<td>{{u.position}}</td>
<td><button style="cursor: pointer;background: none;border: none;" ng-click="del(u.name)">删除</button></td>
</tr>
</table>
<button ng-click="cha()" id="button">查询</button>
<button ng-click="add()" id="button">添加用户</button>
<fieldset style="width: 400px;" ng-show="tianjia">
<legend>添加用户信息</legend>
姓名 <input type="text" ng-model="newname" /><br /><br /> 年龄 <input type="text" ng-model="newage" /><br /><br /> 拼音 <input type="text" ng-model="newpinyin" /><br /><br /> 职位 <input type="text" ng-model="newposition" /><br /><br />
<button ng-click="bao()">保存</button>
</fieldset>
</center>
</body>
</html>
阅读全文
0 0
- 姓名查询 年龄排序 添加用户 删除
- AngularJS 用户名查询、年龄查询、性别查询、全部删除、批量删除、添加用户、修改密码
- html angular+route:模糊查询+限定年龄范围+全部删除+批量删除+修改密码+添加用户
- 用户信息列表 查询+年龄,性别搜索 +全部删除,批量删除+添加用户+修改密码
- 姓名,年龄,成绩的排序
- (angularjs) 数据的增删改查(添加用户,查询年龄,批量删除,全部删除,修改密码) 类似题
- 模糊查询,批量删除, 添加用户,隔行变色,排序,过滤器
- 用户操作(添加、删除、敏感词、排序、查询)
- 姓名+年龄+性别+密码+住址判断添加到表格(批量删除)
- 用户表(查询数据 、添加数据 、排序 、点击删除 、修改密码 、批量删除 、全部删除)
- 根据姓名查询年龄是否超过100
- Angular,添加,删除,查询,排序
- AngularJS添加删除查询排序
- 封装排序专题,按姓名排序,年龄排序,Block排序
- Angular用户查询,按条件排序,批量删除,添加,敏感字屏蔽
- 简单排序,单一删除,隔行换色,模糊查询,添加用户
- 模糊查询全部删除添加用户
- 隔行变色,选中变色,鼠标变小手样式;姓名查询条件 过滤敏感字符 下拉列表排序 非空验证添加信息 点击按钮删除
- mysql、mongodb、python(dataframe).聚合函数的形式,以及报错解决方案
- MySQL 系列(二) 你不知道的数据库操作
- python编程中的if __name__ == 'main': 的作用和原理
- 启动springboot报错
- MVp+RXJava+Retrofit+RecyclerView展示首页和详情页
- 姓名查询 年龄排序 添加用户 删除
- C++四种类型转换
- oracle中对LONG列进行查询
- 二级购物车+编辑+删除
- iTween多圈旋转
- 拓扑排序与关键路径
- Spring 构造注入简单实例
- Java面试题全集(上)2
- 异常处理-三角形