Webページの全選択と逆選択

6013 ワード

1ページ

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>     </title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
<!--   Bootstrap -->
<link href="<%=basePath%>/boostrap/css/bootstrap.min.css"
    rel="stylesheet">

</head>

<body>
    <div class="container">
        <div class="row clearfix">
            <div class="col-md-12 column">
            </div>
        </div>
        <div class="row clearfix">
            <div class="col-md-12 column">
                <c:choose>
                    <c:when test="${listNotexamined_info != null }">
                        <h3>
                            <c:out value="${listNotexamined_info }"></c:out>
                        </h3>
                    </c:when>
                    <c:otherwise>
                        <c:if test="${newsList != null && newsList.size() != 0 }">
                            <form action="root/publishAllNews" method="post">
                                <table class="table">
                                    <thead>
                                        <tr>
                                            <!--      -->
                                             <th><input name="checkAll" id="checkAll" type="checkbox" />
                                                  </th>
                                            <th>  </th>
                                            <th>  </th>
                                            <th>  </th>
                                            <th>  </th>
                                            <th>  </th>
                                            <th>    </th>
                                            <th></th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <c:forEach items="${newsList }" var="news">
                                            <tr>
                                                <!--        -->
                                                <td><input name="newsId" type="checkbox"
                                                    value=<c:out value="${news.id }"/> /></td>
                                                    
                                                    
                                                    <!--  
                                                    
                                                      。。。。。。
                                                    
                                                     -->
                                                    
                                                    
                                                    
                                                 <td><button id="<c:out value="${news.id }"/>"
                                                        class="btn btn-default" onclick="publicNews(this)">  </button></td>
                                            </tr>
                                        </c:forEach>
                                    </tbody>
                                </table>
                                <hr/>
                                <p align="right">
                                    <input type="submit" value="    " class="btn btn-default" />
                                </p>
                            </form>
                        </c:if>
                    </c:otherwise>
                </c:choose>
            </div>
        </div>
    </div>
</body>

2 Js

$(function(){
    
    //      
    $("#checkAll").click(function(){
        
        var isChecked = $(this).prop("checked");
        
         $("input[name='newsId']").prop("checked", isChecked);
    });
});

3バックグラウンド

public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        
        String[] newsIds = request.getParameterValues("newsId");
        
        
    }

4画面