Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- 자바
- TextBox
- MANTIS
- 웹뷰
- jsp
- 컬럼명
- Bootstrap
- asp.net
- Eclipse
- varags
- C#
- Maven
- Android
- SpringSource Tool Suite
- 안드로이드
- javascript
- 이클립스
- Apache Lucene
- Java
- decompiler
- Redirect
- MS-SQL
- 자바스크립트
- STS
- 웹 서비스
- scrollView
- MSsql
- Web Service
- html
- WebView
Archives
- Today
- Total
bboks.net™
JSP Checkbox를 포함한 리스트페이지에서 멀티 체크와 삭제 본문
송신측 소스
<html>
<head>
<script language="javascript" type="text/javascript">
function checkAll(checkList, boolCheck) {
varchkSize = 0;
checkedCount = checkList.length;
if (typeof (checkedCount) != "undefined") {
for ( var i = 0; i < chkSize; i++) {
checkList[i].checked = boolCheck;
}
}
}
function checkDel() {
var chkFirList = document.getElementsByName('check');
var arrFir = new Array();
var cnt = 0;
for ( var idx = chkFirList.length - 1; 0 <= idx; idx--) {
if (chkFirList[idx].checked) {
arrFir[cnt] = chkFirList[idx].value;
cnt++;
}
}
if (arrFir.length != 0) {
document.form1.submit();
} else {
alert('삭제할 **를 선택하세요.');
return;
}
}
</script>
</head>
<body>
<form name="form1" method="post" action="formprocess.jsp" id="checkList">
<input type="checkbox" onclick="javascript:checkAll(document.getElementsByName('check'), this.checked);" />전체선택
<input type="checkbox" name="check" value="1" /> 1
<input type="checkbox" name="check" value="2" /> 2
<input type="checkbox" name="check" value="3" /> 3
<input type="checkbox" name="check" value="4" /> 4
<input type="checkbox" name="check" value="5" /> 5
<input type="button" value="삭제" onclick="checkDel();">
</form>
</body>
</html>
<head>
<script language="javascript" type="text/javascript">
function checkAll(checkList, boolCheck) {
varchkSize = 0;
checkedCount = checkList.length;
if (typeof (checkedCount) != "undefined") {
for ( var i = 0; i < chkSize; i++) {
checkList[i].checked = boolCheck;
}
}
}
function checkDel() {
var chkFirList = document.getElementsByName('check');
var arrFir = new Array();
var cnt = 0;
for ( var idx = chkFirList.length - 1; 0 <= idx; idx--) {
if (chkFirList[idx].checked) {
arrFir[cnt] = chkFirList[idx].value;
cnt++;
}
}
if (arrFir.length != 0) {
document.form1.submit();
} else {
alert('삭제할 **를 선택하세요.');
return;
}
}
</script>
</head>
<body>
<form name="form1" method="post" action="formprocess.jsp" id="checkList">
<input type="checkbox" onclick="javascript:checkAll(document.getElementsByName('check'), this.checked);" />전체선택
<input type="checkbox" name="check" value="1" /> 1
<input type="checkbox" name="check" value="2" /> 2
<input type="checkbox" name="check" value="3" /> 3
<input type="checkbox" name="check" value="4" /> 4
<input type="checkbox" name="check" value="5" /> 5
<input type="button" value="삭제" onclick="checkDel();">
</form>
</body>
</html>
수신측 소스
<html>
<head>
</head>
<body>
<%
String[] checks = request.getParameterValues("check");
int checklen = checks.length;
try {
for(int i=0; i<checklen; i++) {
out.println(checks[i]+";");
}
}
catch(Exception ex) {
out.println("exception occured");
}
%>
</body>
</html>
<head>
</head>
<body>
<%
String[] checks = request.getParameterValues("check");
int checklen = checks.length;
try {
for(int i=0; i<checklen; i++) {
out.println(checks[i]+";");
}
}
catch(Exception ex) {
out.println("exception occured");
}
%>
</body>
</html>
소스파일
[참조] JSP) checkbox (리스트페이지 멀티 체크&삭제)