显示数据
Posted mamingyuan
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了显示数据相关的知识,希望对你有一定的参考价值。
@{ Layout = null; } <!DOCTYPE html> <html> <head> <script src="~/Scripts/jquery-1.7.2-min.js"></script> <meta name="viewport" content="width=device-width" /> <title>Show</title> <script type="text/javascript"> var DDpage=1; var Count=0; $(function () { $.ajax({ url: ‘http://localhost:8889/SchoolWebserice.asmx/GetSchools‘, type: ‘post‘, success: function (data) { $(data).each(function (index, data) { $("#s").append("<option value=‘" + data.SchoolCode + "‘>" + data.SchoolName + "</option>") }) } }) $("#s").change(function () { $.ajax({ url: ‘http://localhost:8889/ClassWebService.asmx/GetClasses‘, type: ‘post‘, data: { SchoolCode: $("#s").val() }, success: function (data) { $("#c option").not(":first").remove(); $(data).each(function (index, data) { $("#c").append("<option value=‘" + data.ClassCode + "‘>" + data.ClassName + "</option>") }) } }) }) show(); }) function show() { $.ajax({ url: ‘http://localhost:8889/StudentWebService.asmx/GetStudent‘, type: ‘post‘, data: { Dpage: DDpage, ClassCode: $("#c").val(), SchoolCode: $("#s").val(), StudentName: $("input[name=StudentName]").val() }, success: function (data) { Count = data.Count; DDpage = data.Dpage; $("#table tr").not(":first").remove(); $(data.Ddata).each(function (index, data) { var mark = null; mark += "<tr>"; mark += "<td>" + ( (DDpage-1)*3 +index+ 1) + "</td>"; mark += "<td>" + data.SchoolName + "</td>"; mark += "<td>" + data.ClassName + "</td>"; mark += "<td>" + data.StudentName + "</td>"; mark += "<td>" + (data.Gender == 0 ? "男" : "女") + "</td>"; mark += "<td><a href=‘#‘ onclick=‘Delete(this," + data.StudentId + ")‘>删除</a><a href=‘update?StudentId=" + data.StudentId + "‘>修改</a></td>"; mark += "</tr>"; $("#table").append(mark) }) } }) } function first() { DDpage = 1; show() } function up() { if(DDpage-1<1) { alert(‘已经是第一页了‘) } else { DDpage--; show() } } function next() { if (DDpage +1 >Count) { alert(‘已经是最后一页了‘) } else { DDpage++; show() } } function last() { DDpage = Count; show() } function Delete(obj, id) { $.ajax({ url: ‘http://localhost:8889/StudentWebService.asmx/Delete‘, type: ‘post‘, data: { StudentId: id }, success:function(data) { if (data > 0) { alert(‘删除成功‘) location.href = ‘/Student/Show‘ } else alert(‘删除失败‘) } }) } </script> </head> <body> <select id="s"> <option value="0">请选择</option> </select> <select id="c"> <option value="0">请选择</option> </select> <input type="text" name="StudentName" /> <input type="button" value="查询" onclick=" Dpage = 1; show()" /> <table id="table"> <tr> <td> 序号 </td> <td> 学校名称 </td> <td> 班级名称 </td> <td> 姓名 </td> <td> 性别 </td> <td> 操作 </td> </tr> </table> <div> <a href="#" onclick="first()">首页</a> <a href="#" onclick="up()">上一页</a> <a href="#" onclick="next()">下一页</a> <a href="#" onclick="last()">尾页</a> </div> </body> </html>
@{ Layout = null;}
<!DOCTYPE html>
<html><head> <script src="~/Scripts/jquery-1.7.2-min.js"></script> <meta name="viewport" content="width=device-width" /> <title>Show</title> <script type="text/javascript"> var DDpage=1; var Count=0; $(function () { $.ajax({ url: ‘http://localhost:8889/SchoolWebserice.asmx/GetSchools‘, type: ‘post‘,
success: function (data) { $(data).each(function (index, data) { $("#s").append("<option value=‘" + data.SchoolCode + "‘>" + data.SchoolName + "</option>") }) } }) $("#s").change(function () { $.ajax({ url: ‘http://localhost:8889/ClassWebService.asmx/GetClasses‘, type: ‘post‘, data: { SchoolCode: $("#s").val() }, success: function (data) { $("#c option").not(":first").remove(); $(data).each(function (index, data) { $("#c").append("<option value=‘" + data.ClassCode + "‘>" + data.ClassName + "</option>") }) } }) }) show(); }) function show() { $.ajax({ url: ‘http://localhost:8889/StudentWebService.asmx/GetStudent‘, type: ‘post‘, data: { Dpage: DDpage, ClassCode: $("#c").val(), SchoolCode: $("#s").val(), StudentName: $("input[name=StudentName]").val()
}, success: function (data) { Count = data.Count; DDpage = data.Dpage; $("#table tr").not(":first").remove(); $(data.Ddata).each(function (index, data) { var mark = null; mark += "<tr>"; mark += "<td>" + ( (DDpage-1)*3 +index+ 1) + "</td>"; mark += "<td>" + data.SchoolName + "</td>"; mark += "<td>" + data.ClassName + "</td>"; mark += "<td>" + data.StudentName + "</td>"; mark += "<td>" + (data.Gender == 0 ? "男" : "女") + "</td>"; mark += "<td><a href=‘#‘ onclick=‘Delete(this," + data.StudentId + ")‘>删除</a><a href=‘update?StudentId=" + data.StudentId + "‘>修改</a></td>"; mark += "</tr>"; $("#table").append(mark) }) } }) } function first() { DDpage = 1; show() } function up() { if(DDpage-1<1) { alert(‘已经是第一页了‘) } else { DDpage--; show() } } function next() { if (DDpage +1 >Count) { alert(‘已经是最后一页了‘) } else { DDpage++; show() } } function last() { DDpage = Count; show() } function Delete(obj, id) { $.ajax({ url: ‘http://localhost:8889/StudentWebService.asmx/Delete‘, type: ‘post‘, data: { StudentId: id }, success:function(data) { if (data > 0) { alert(‘删除成功‘) location.href = ‘/Student/Show‘ } else alert(‘删除失败‘) } }) } </script></head><body> <select id="s"> <option value="0">请选择</option> </select> <select id="c"> <option value="0">请选择</option></select> <input type="text" name="StudentName" /> <input type="button" value="查询" onclick=" Dpage = 1; show()" /> <table id="table"> <tr> <td> 序号 </td> <td> 学校名称 </td> <td> 班级名称 </td> <td> 姓名 </td> <td> 性别 </td> <td> 操作 </td> </tr> </table> <div> <a href="#" onclick="first()">首页</a> <a href="#" onclick="up()">上一页</a> <a href="#" onclick="next()">下一页</a> <a href="#" onclick="last()">尾页</a> </div></body></html>
以上是关于显示数据的主要内容,如果未能解决你的问题,请参考以下文章