增删改查——————增

<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- 上述3个meta标签*必须*放在最前面,任何其他内容都*必须*跟随其后! -->
<title>学员管理界面</title>
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="css/normalize.css">
<link rel="stylesheet" href="学员管理.css"/>

</head>
<body>
<div class="carousel">
<div class="row">
<div class="col-xs-8 col-xs-push-2">
<a href="登陆.html">登陆</a>
<a href="注册.html">注册</a>
</div>
</div>
<div class="row">
<div class="col-xs-2 col-xs-push-5">
<h1>学员管理</h1>
</div>
</div>
<div class="row">
<div class="col-xs-10 col-xs-push-1" style="text-align: center">
<table class="table table-striped table-bordered">
<tr>
<th>姓名</th>
<th>年龄</th>
<th>性别</th>
<th></th>
</tr>
<tbody id="tbody">

</tbody>
</table>
</div>
</div>
<div class="col-xs-8 col-xs-push-2" id="xiugai">
<input type="hidden" name="id1"/>
姓名:<input type="text"/>
年龄:<input type="text"/>
性别:<input type="text"/>
<input type="button" value="修改"/>
</div>
<div class="col-xs-8 col-xs-push-2" style="margin-top: 50px">
姓名:<input type="text" id="name"/>
年龄:<input type="text" id="age"/>
性别:<input type="radio" name="1" value="男"/>男
<input type="radio" name="1" value="女"/>女
<input type="button" value="增加"/>
</div>
</div>

<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->

<script src="js/jquery-1.11.2-min.js"></script>
<script type="text/javascript" src="js/common.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="js/bootstrap.min.js"></script>
<script type="text/javascript">

$(function(){
// 增加学员列表
$(":button[value=增加]").click(function(){

var students=get("students");
if(!students){
students=[]
}
students.push({
name1:$("#name").val(),
age1:$("#age").val(),
sex:$(":radio[name=1]:checked").val(),
id:generateId("students")
});
save("students",students);
var studentsa="";
$(students).each(function(){
studentsa += "<tr>"
+ "<td>" + this.name1 + "</td>"
+ "<td>" + this.age1+ "</td>"
+ "<td>" + this.sex + "</td>"
+ "<td>"
+ "<input student-id='" + this.id + "' type=\"button\" value=\"修改1\">"
+ "<input student-id='" + this.id + "'type=\"button\" value=\"删除\">"
+ "</td>"
+ "</tr>";
});
$("#tbody").html(studentsa);
});
</script>
</body>
</html>

posted on 2016-06-06 01:46  名字怎么取  阅读(266)  评论(0编辑  收藏  举报

导航