|
||
|
|||
|
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: Java 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>
<%
Last edited by helloworld922; 12-03-2010 at 01:25 PM. |
|
|||
|
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 |
|
|||
|
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.
__________________
acekard 2 |
| The Following User Says Thank You to heronfisher For This Useful Post: | ||
Json (15-03-2010) | ||
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Checking in. | Johannes | Member Introductions | 7 | 13-08-2009 11:11 AM |
| viewing a single record from database | hundu | JavaServer Pages: JSP & JSTL | 1 | 05-07-2009 12:56 PM |
| setEnabled causing checkbox to deselect | dewboy3d | AWT / Java Swing | 3 | 21-05-2009 04:36 PM |
| [SOLVED] checking if it is a character? | luke | File I/O & Other I/O Streams | 10 | 20-05-2009 09:55 AM |
| checking individual digits of an int | Konnor | Java Theory & Questions | 2 | 04-02-2009 04:24 PM |