码迷,mamicode.com
首页 > 其他好文 > 详细

显示数据

时间:2018-07-29 23:30:27      阅读:230      评论:0      收藏:0      [点我收藏+]

标签:选择   doctype   jquer   getc   rem   name   button   javascrip   value   

@{
    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>

 

显示数据

标签:选择   doctype   jquer   getc   rem   name   button   javascrip   value   

原文地址:https://www.cnblogs.com/mamingyuan/p/9387982.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!