dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: prob.. confirm message

  1. #1
    Join Date
    Oct 2004
    Posts
    169

    prob.. confirm message

    hey...

    its the updation query.In this page when i click the update button it updates the values in the row..and this query is working...

    I want to do that..when i click a update button it gives me a confirms message whether did u want to update the row and also displaying the particular gl_code no in that confirms message.when i click on yes it updates the row..otherwise it doesnot.

    after updation it shows message that this particular gl_code no is has been updated.

    <%
    String action = request.getParameter("action");

    if (action != null && action.equals("update")) {
    conn.setAutoCommit(false);


    PreparedStatement pstatement = conn.prepareStatement(
    "UPDATE gl_mast SET gl_descr = ?, db_amt = ?, " +
    "cr_amt = ?, gl_type = ? , gl_pct = ? WHERE gl_code=?");

    pstatement.setString(1, request.getParameter("gl_descr"));
    pstatement.setFloat(2,Float.parseFloat(request.getParameter("db_amt")));
    pstatement.setFloat(3,Float.parseFloat(request.getParameter("cr_amt")));
    pstatement.setString(4, request.getParameter("gl_type"));
    pstatement.setFloat(5,Float.parseFloat(request.getParameter("gl_pct")));
    pstatement.setInt(6,Integer.parseInt(request.getParameter("gl_code")));

    int rowCount = pstatement.executeUpdate();
    conn.setAutoCommit(false);
    conn.setAutoCommit(true);
    }



    %>


    <%

    Statement statement = conn.createStatement();

    ResultSet rs = statement.executeQuery
    ("SELECT * FROM gl_mast ");

    %>


    <form action="gl_update.jsp" method="get">
    <input type="hidden" value="update" name="action">
    <tr>
    <td><input value="<%= rs.getInt("gl_code") %>" size="5" name="gl_code"></td>
    <td><input value="<%= rs.getString("gl_descr") %>" size="55" name="gl_descr"></td>
    <td><input value="<%= rs.getFloat("db_amt") %>" size="12" name="db_amt"></td>
    <td><input value="<%= rs.getFloat("cr_amt") %>" size="12" name="cr_amt"></td>
    <td><input value="<%= rs.getString("gl_type") %>" size="3" name="gl_type"></td>
    <td><input value="<%= rs.getFloat("gl_pct") %>"size="5" name="gl_pct"></td>
    <td><input type="submit" value="Update"></td>
    </tr>
    </form>

  2. #2
    Join Date
    Dec 2002
    Location
    Calgary, Canada
    Posts
    6,136
    you can use JavaScript for such functionality...the following line
    <input type="submit" value="Update">

    should be like this

    <input type="submit" value="Update" onclick="return confirm('do u really want to submit?');"/>

    Now I want to suggest here that you must want to remove your business logic code(database queries) to some hidden part of the application, using db queries in a jsp is probably oneof the worst practices that one can resort to in web programming with java.
    Cheers

    Khalid

    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles