how to delete record from checking checkbox value.
i would like to use jsp and java to write a add/edit/delete function.
I am a beginner, now i dont know how to create a java as a database layer in which i connect to database and write sql statement to insert/delete/update the table.
afterwards, i would like to use jsp to create a layout.
now , I don't know how to check the checkbox value from the table and then the user click the delete button to delete all ticked record in the table.
I already write the code in jsp as belows:
Code :
<INPUT TYPE="submit" value="Delete" onClick="">
while(rs.next())
{
%>
<tr><td><%=rs.getString(1) %></td>
<td><%=rs.getString(2) %></td>
<td><%=rs.getString(3) %></td>
<td><center><input type="checkbox" name="del" ></center></td></tr>
<%
Re: how to delete record from checking checkbox value.
To use java to access the database, first please read about the JDBC apis.
and then learn how to use javascript to access DOM objects
Cheers
Re: how to delete record from checking checkbox value.
If your page has a control something like this:
<input type="checkbox" name="idValue" value="${myObj.id}">
Then in the servlet that you go to when submitting the form:
String[] idsToDelete = request.getParameterValues("idValue");
That will give you an array of all the ids that were selected that need to be deleted.
Loop through that array, and delete them one by one.