Thread: jsp doubt

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    7
    Rep Power
    0

    jsp doubt


    Hi,
    How do i update a row in a database when a checkbox is checked?

    nandhinee
  2. #2
  3. PHP & Java Error Master
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    My Computer
    Posts
    1,219
    Rep Power
    0
    Well first of all, a form has to be submitted, because this isn't javascript. Java/JSP is serverside.
    You can still do what you want, but a form would have to be submitted to do that. The code to update would look something like this
    Code:
    // Do your connection stuff
    Connection conn = null;
    Statement stmt = null;
    ResultSet rs = null;
    
    if(request.getParameter("checkbox_name") == "yes")
    {
         String sql = "UPDATE tablename SET (val1 = 'val1', val2  = 'val2', val3 = 'val3'";
         
         stmt = conn.createStatement();
         rs = stmt.executeQuery(sql);
    }
    That would assume you had a checkbox named checkbox_name and it's value was yes.
    Last edited by StevenC; July 15th, 2003 at 08:46 AM.
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    7
    Rep Power
    0
    Thanks Stephen.
  6. #4
  7. PHP & Java Error Master
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    My Computer
    Posts
    1,219
    Rep Power
    0
    Steven, not Stephen
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Posts
    7
    Rep Power
    0
    Iam sorry for that.Thanks Steven.
  10. #6
  11. PHP & Java Error Master
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jun 2003
    Location
    My Computer
    Posts
    1,219
    Rep Power
    0
    No biggie

IMN logo majestic logo threadwatch logo seochat tools logo