티스토리 뷰

Develop/Language

[JSP] checkbox 배열로 받기

빼인트 2011. 2. 14. 05:20

보내는 html 또는 JSP


<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]);
}
%>



댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/05   »
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 31
글 보관함