본문 바로가기
JSP

[ JSP ] 체크박스 여러개 값 넘기기

by 정윤재 2008. 11. 10.

//checkBox.jsp


<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title>Insert title here</title>
</head>
<body>
<form action="checkBoxProc.jsp" name="f1">

 <input type="checkbox" name="c1" value="1">1<br>
 <input type="checkbox" name="c1" value="2">2<br>
 <input type="checkbox" name="c1" value="3">3<br>
 <input type="checkbox" name="c1" value="4">4<br>
 <input type="checkbox" name="c1" value="5">5<br>

<input type="submit" value="전송">
</body>
</html>

===========================================
//checkBoxProc.jsp

<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<%
String[] str = request.getParameterValues("c1");

%>

<%for(int i=0;i<str.length;i++){
%>
<%=str[i] %><br>
<%} %>


댓글