How to update data using webpage submit button?
Posted by: mat bar
Date: March 17, 2014 01:51PM

My question is how to update data using webpage submit button?

In theory , i need to get parameter from field 1("getint") and after button Dispense[2] is clicked database data[3] is decremented by value from field 1. So for example if drug number 3 shows us quantity 21 and user wants dispense 4 boxes of aranesp drug field gonna be updated and 4 boxes are going to be decremented.

This is my code

<%@ page language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

Connection conn = null;
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/database","root", "asdqwe");

<title>Successfully Login by JSP</title>
<link rel="stylesheet" type="text/css" href="resources/css/maincss.css">
<link rel="stylesheet" type="text/css" href="resources/css/style_table.css">
<script type="text/javascript">

function menuLogOut()


<div id="loggedas_stock_check">
<img src=img/logged_as.png border="0">
	<div id=loggedas_nick_stock_check>
	out.print(session.getAttribute("suserid")+ "</b>"+"<br>");

<div id="wyloguj_stock_check">
<a href="" onclick="javascript:menuLogOut();"><img src=img/logout.png border="0"></a>


<form method="post">

<table class="bordered">

        <th>Drug Name</th>
        <th>Dis Qty</th>            

String query="select * from drugs";

Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery(query);

   <td><%=rs.getInt("drugid") %></td> 
   <td><%=rs.getString("drugname") %></td> 
   <td><%=rs.getString("strength") %></td>
   <td><%=rs.getInt("drugquant") %></td>
   <td><INPUT TYPE="TEXT" NAME="getint" SIZE="7">
       <INPUT TYPE="SUBMIT" VALUE="Dispense" NAME="B1"></td>
catch(Exception e)



Could anyone help me please?

Options: ReplyQuote

Written By
How to update data using webpage submit button?
March 17, 2014 01:51PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.