본문 바로가기
Web Programing!/JAVA / JSP

[JSP] 체크박스로 넘어온 값 배열로 받기 - getParameterValues

by 어설픈봉봉이 2011. 9. 14.
반응형
SMALL






보내는 html

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
</head>
<body>
<table width="630" border="0" cellspacing="0" cellpadding="0">
   <form name="frm" method="POST" action="checkbox.jsp">
   <tr>
      <td>&nbsp;체크박스1: <input name="chkbox" type="checkbox" value="1"></td>
      <td>&nbsp;체크박스2: <input name="chkbox" type="checkbox" value="2"></td>
      <td>&nbsp;체크박스3: <input name="chkbox" type="checkbox" value="3"></td>
      <td>&nbsp;체크박스4: <input name="chkbox" type="checkbox" value="4"></td>
      <td>&nbsp;체크박스5: <input name="chkbox" type="checkbox" value="5"></td>
   </tr>
   <tr>
      <td height="10"></td>
   </tr>
   <tr>
      <td align="center" colspan="5"><input name="button" type="submit" value="보내기"></td>
   </tr>
   </form>
</table>
</body>
</html>

 

받는 JSP

<%
String[] chkbox = request.getParameterValues("chkbox");

for( int i = 0; i < chkbox.length; i++ )
{
out.println(chkbox[i]);
}

%> 




반응형