i am trying to get values of checkboxes to insert them later on in database.
It is ok that unchecked checkboxes will not be sent to my servlet but the problem that i have when cheking more than one checkboxe it returns just the first I’am doing like that im my JSP:
<td><input type=checkbox id=\""+i+"\" name=cbo value=<%=object.getNom()+ object.getPrenom() %> /> <%=object.getNom()+object.getPrenom()%></td>
And In the servlet the following:
String[] checkboxes = request.getParameterValues("cbo");
System.out.println("operators checked are:" + checkboxes[i]);
Like you see I want to get all the values checked.
but if i check more than one only the first CB is shown in my servlet.
Thinks for help.
The
request.getParameterValues()returns an array of values for multiple parameters with the same name found in the request.If your request is OK, and by that I mean
action?cbo=val1&cbo=val2&cbo=val3etc, then, after you submit the form to your servlet,checkboxesshould be["val1", "val2", "val3"].First check your request.
And one question: the following is in a loop, right?