how to pass a dynamic value in request.getParameter()
843838Jun 6 2006 — edited Jun 7 2006hello,
I am new to JSP development so all help is appreciated. I am trying to create a form that shows records from a table with a checkbox next to each row. When a user checks several of the checkboxes and submits the form, then those records are deleted from the table.
The only way I could think of to do this is to dynamically name the checkboxes. Each time the while loops, the checkbox name is populated dynamically using this code:
<% int i = 1 ;
while result(next) {
%>
<input type = "checkbox" name = "<%= i %>" value ="<%=result.getString("myName") %>"
<% i = i+1;
}
%>
When I check several checkboxes and sumbit the form, I need to collect all the checkbox names that were checked and put them in a list or array or something, so that when I write my DELETE sql stmt, I can go thru the collection of checkbox names I grabbed and detele the rows.
I am not really sure how to place a dyamic value in the request.getParameter() field so I need help in this part.
Here is what I have in my submit form so far:
<% for (int i = 1; i <= 10; i++) {
if (request.getParameter(??????) != null {
put this in some array or collection;
}
%>
Thank you in advance to anyone who responds.
JavaNewbie :o)