[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index] [Home]

Can't get multiple checkbox's value


here is my jsp,when i check two checkboxes with the same name,i can only get
the first checkbox's value,why,i tested in ASP,i can get all my checked
checkbox's values,is this a gnujsp's bug?

<%@ page info="JSP Implict Object¡¡£­¡¡request" %>
<%@ page import="java.util.Enumeration" %>

<html>
<head><title>JSP Implict Object¡¡£­¡¡request</title></head>
<body>

<%!
   Enumeration Enum;
   Object Obj;
   String StrArray[];
   int i;
%>

<form action="request.jsp" method="post">
   FormInputCheckBox£º<br>
      <input type="checkbox" name="FormInputCheckBox"
value="CheckBox1">CheckBox1<br>
      <input type="checkbox" name="FormInputCheckBox"
value="CheckBox2">CheckBox2<br>
      <input type="checkbox" name="FormInputCheckBox"
value="CheckBox3">CheckBox3<br>
   <input type="submit">
</form>

<%
   Enum = request.getParameterNames();
   while(Enum.hasMoreElements()){
      Obj = Enum.nextElement();
      StrArray = request.getParameterValues((String)Obj);
%>
   <%= Obj%>£º
   <%
      for(i=0;i<StrArray.length;i++){
         out.print(StrArray[i]);
      }
   %>
   <br>
<%
   }
%>

</body>
</html>