A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

[学习交流] 【成都校区】

© 。泉哥哥 初级黑马   /  2019-1-24 13:56  /  546 人查看  /  0 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文


<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html lang="zh-CN">
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <style type="text/css">
        td, th {
            text-align: center;
        }

        #sousuo{
            float: left;
        }
        #gongneng{
            float: right;
        }
        #jilu{
            font-size: 25px;
            margin-left: 10px;
        }
    </style>

    <script>
        function Del(id) {
            if (confirm("您确定要删除吗")){
                location.href="${pageContext.request.contextPath}/DelServlet?id="+id;
            }
        }

        window.onload=function () {
            document.getElementById("fir").onclick=function () {
                var cbs = document.getElementsByName("cb");
                for (var i=0;i<cbs.length;i++){
                    cbs[i].checked=this.checked;
                }
            }
            document.getElementById("delAll").onclick=function () {
                var cbs = document.getElementsByName("cb");
                var b=false;
                for (var i=0;i<cbs.length;i++){
                    if (cbs[i].checked){
                        b=true;
                        break;
                    }
                }

                if (b==true){
                    if (confirm("您确定要删除选中的数据吗?")){
                        document.getElementById("form").submit();
                    }
                } else {
                    alert("请选中需要删除的数据")
                }
            }
        }
    </script>
</head>
<body>



<div class="container">
    <h3 style="text-align: center">用户信息列表</h3>

    <div id="sousuo">
        <form action="${pageContext.request.contextPath}/FenyeServlet" method="post" class="form-inline">
            <div class="form-group">
                <label for="name">姓名</label>
                <input type="text" class="form-control" value="${condition.name}" name="name" id="name" placeholder="Jane Doe">
            </div>
            <div class="form-group">
                <label for="adderss">籍贯</label>
                <input type="email" class="form-control" value="${condition.address}" name="address" id="adderss" placeholder="jane.doe@example.com">
            </div>
            <div class="form-group">
                <label for="email">邮箱</label>
                <input type="email" class="form-control" name="email" value="${condition.name}" id="email" placeholder="jane.doe@example.com">
            </div>
            <button type="submit" class="btn btn-default">查询</button>
        </form>
    </div>

    <div id="gongneng">
        <tr>
            <td colspan="8" align="center">
                <a class="btn btn-primary" href="${pageContext.request.contextPath}/add.jsp" id="add">添加联系人</a></td>
        </tr>
        <tr>
            <td colspan="8" align="center">
            <a class="btn btn-primary" id="delAll" href="javascript:void (0)">删除选中</a></td>
        </tr>
    </div>
    <form id="form" action="${pageContext.request.contextPath}/DelAllServlet" method="post">
    <table border="1" class="table table-bordered table-hover">
        <tr class="success">
            <th><input type="checkbox" name="fir" id="fir"></th>
            <th>编号</th>
            <th>姓名</th>
            <th>性别</th>
            <th>年龄</th>
            <th>籍贯</th>
            <th>QQ</th>
            <th>邮箱</th>
            <th>操作</th>
        </tr>

         <c:forEach items="${pb.list}" var="user" varStatus="i">
            <tr>
                <td><input type="checkbox" value="${user.id}" name="cb"></td>
                <td>${i.count}</td>
                <td>${user.name}</td>
                <td>${user.gender}</td>
                <td>${user.age}</td>
                <td>${user.address}</td>
                <td>${user.QQ}</td>
                <td>${user.email}</td>
                <td><a class="btn btn-default btn-sm"  href="${pageContext.request.contextPath}/upServlet?id=${user.id}">修改</a>&nbsp;
                    <a class="btn btn-default btn-sm" name="del" id="del" href="javascript:Del(${user.id});">删除</a></td>
            </tr>
          </c:forEach>

    </table>
    </form>
    <nav>

        <ul class="pagination">
            <%--上一页--%>
            <c:if test="${pb.yema==1}">
                <li class="disabled">
            </c:if>
            <c:if test="${pb.yema!=1}">
                <li >
            </c:if>
                <a href="${pageContext.request.contextPath}/FenyeServlet?yema=${pb.yema-1}" aria-label="Previous">
                    <span aria-hidden="true">&laquo;</span>
                </a>
            </li>

                <%--页码--%>
            <c:forEach begin="1" end="${pb.gongyeshu}" var="i">
                <c:if test="${pb.yema==i}">
                    <li class="active"><a href="${pageContext.request.contextPath}/FenyeServlet?yema=${i}">${i}</a></li>
                </c:if>
                <c:if test="${pb.yema!=i}">
                    <li><a href="${pageContext.request.contextPath}/FenyeServlet?yema=${i}">${i}</a></li>
                </c:if>
            </c:forEach>


            <%--下一页--%>
             <c:if test="${pb.yema==pb.gongyeshu}">
                <li class="disabled">
             </c:if>
              <c:if test="${pb.yema!=pb.gongyeshu}">
                <li>
              </c:if>

                    <a href="${pageContext.request.contextPath}/FenyeServlet?yema=${pb.yema+1}" aria-label="Next">
                    <span aria-hidden="true">&raquo;</span>
                </a>
            </li>
            <span id="jilu">${pb.zongshu}条记录,共${pb.gongyeshu}</span>
        </ul>
    </nav>


</div>

</body>
</html>

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马