check box!
in Java
체크박스 넣기
check box
$(document).ready(function(){
// 체크
var incheck = $("input[name=noticeNoList]") // 반복적으로 나와서
$('#chkAll').click(function(){
if($('#chkAll').is(':checked')) incheck.prop('checked', true);
else incheck.prop('checked', false);
});
$("input[name=noticeNoList]").click(function() {
var total = $("input[name=noticeNoList]").length;
var checked = $("input[name=noticeNoList]:checked").length;
if(total != checked) $("#chkAll").prop("checked", false);
else $("#chkAll").prop("checked", true);
});
})
<body>
<a href="${contextPath}/notice/savePage">새 공지 작성</a>
<hr>
<form action="${contextPath}/notice/removeList">
<button>선택삭제</button><br>
<table border="1">
<thead>
<tr>
<td>
<label for="chkAll">전체선택</label>
<input type="checkbox" id="chkAll" class="blind"/>
</td>
<td>번호</td>
<td>제목</td>
<td>작성일</td>
</tr>
</thead>
<tbody>
<c:forEach items="${notices}" var="notice">
<tr data-notice_no="${notice.noticeNo}">
<td><input type="checkbox" name="noticeNoList" value="${notice.noticeNo}"></td> <!-- private Long noticeNo; -->
<td>${notice.noticeNo}</td> <!-- id로 주면 중복 id 발생 -->
<td>${notice.title}</td>
<td>${notice.created}</td>
</tr>
</c:forEach>
</tbody>
</table>
</form>
</body>