Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: how to delete record from checking checkbox value.

  1. #1
    Junior Member
    Join Date
    Dec 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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:
    <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; March 12th, 2010 at 09:25 AM.


  2. #2
    Junior Member
    Join Date
    Mar 2010
    Location
    Mauritius
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 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

  3. #3
    Junior Member
    Join Date
    Mar 2010
    Posts
    4
    Thanks
    0
    Thanked 4 Times in 2 Posts

    Default 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.

  4. The Following User Says Thank You to heronfisher For This Useful Post:

    Json (March 15th, 2010)

Similar Threads

  1. Checking in.
    By Johannes in forum Member Introductions
    Replies: 7
    Last Post: August 13th, 2009, 06:11 AM
  2. Jsp code which will enable to view a single row from the Database
    By hundu in forum JavaServer Pages: JSP & JSTL
    Replies: 1
    Last Post: July 5th, 2009, 07:56 AM
  3. setEnabled causing checkbox to deselect
    By dewboy3d in forum AWT / Java Swing
    Replies: 3
    Last Post: May 21st, 2009, 11:36 AM
  4. [SOLVED] Getting Exception " java.util.InputMismatchException" in scanner package
    By luke in forum File I/O & Other I/O Streams
    Replies: 10
    Last Post: May 20th, 2009, 04:55 AM
  5. Replies: 2
    Last Post: February 4th, 2009, 12:24 PM