...

View Full Version : list box refresh page



sher_amf
07-13-2008, 01:11 AM
what i want is that that everytime i select from the drop down menu the qty would change according to my database

so when i choose raw A the qty would change into 34
and when i choose Raw B the qty would change into 56

the number of qty are from my sql database

here is my code


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Update Raw Materials</title>
<style type="text/css">
<!--
#apDiv1 {
position:absolute;
width:308px;
height:341px;
z-index:1;
left: 132px;
top: 152px;
background-color: #FFFFFF;
}
#apDiv2 {
position:absolute;
width:105px;
height:115px;
z-index:2;
left: 13px;
top: 14px;
}
#apDiv3 {
position:absolute;
width:230px;
height:399px;
z-index:3;
left: 787px;
top: 160px;
}
#Layer1 {
position:absolute;
width:200px;
height:115px;
z-index:4;
left: 125px;
top: 17px;
}
#Layer2 {
position:absolute;
width:863px;
height:287px;
z-index:5;
left: 146px;
top: 187px;
}
#Layer3 { position:absolute;
width:116px;
height:115px;
z-index:5;
top: 154px;
}
#apDiv4 {
position:absolute;
width:107px;
height:19px;
z-index:6;
top: 146px;
left: 886px;
}
body {
background-image: url(images/bgimage%20copy.png);
background-repeat: no-repeat;
}
#apDiv5 { position:absolute;
width:74px;
height:24px;
z-index:9;
left: 919px;
top: 144px;
}
#apDiv {position:absolute;
width:200px;
height:21px;
z-index:8;
left: 124px;
top: 144px;
}
#apDiv6 {
position:absolute;
width:601px;
height:115px;
z-index:10;
left: 155px;
top: 222px;
}
#apDiv7 {
position:absolute;
width:252px;
height:24px;
z-index:5;
left: 151px;
top: 146px;
}
.style8 {
color: #FFFFFF;
font-family: Calibri;
}
.style9 {
color: #FFFFFF;
font-weight: bold;
font-family: Calibri;
}
#apDiv9 { position:absolute;
width:135px;
height:236px;
z-index:10;
left: 2px;
top: 168px;
}
#apDiv8 {
position:absolute;
width:421px;
height:22px;
z-index:11;
left: 156px;
top: 180px;
}
.style10 {
font-size: 18px;
font-weight: bold;
font-family: Calibri;
}
.style11 {color: #000000}
.style13 {font-family: Calibri}
#apDiv10 {
position:absolute;
width:485px;
height:209px;
z-index:12;
left: 155px;
top: 225px;
}
#apDiv11 {
position:absolute;
width:200px;
height:115px;
z-index:12;
left: 154px;
top: 219px;
}
.style14 {color: #FFFFFF}
#apDiv12 {
position:absolute;
width:360px;
height:33px;
z-index:13;
left: 663px;
top: 175px;
}
#apDiv13 {
position:absolute;
width:200px;
height:115px;
z-index:12;
left: 157px;
top: 217px;
}
.style18 {color: #000066; }
.style20 {color: #0000FF}
-->
</style>
</head>
<%@ page import="java.sql.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.util.*"%>
<body>
<div class="style13" id="apDiv9">
<table width="135" border="0">
<tr>
<th bgcolor="#000099" scope="col"><div align="left"><span class="style8">Raw Materials</span></div></th>
</tr>
<tr>
<th bgcolor="#FFFFFF" scope="row"><div align="left" class="style18"><a href="VPinventoryreceived.jsp">Add </a></div></th>
</tr>
<tr>
<th bgcolor="#FFFFFF" scope="row"><div align="left" class="style18"><a href="VPinventoryreorder.jsp">Re-Order</a></div></th>
</tr>
<tr>
<th bgcolor="#FFFFFF" scope="row"><div align="left" class="style20"><a href="vpinventoryupdateraw.jsp">Update</a></div></th>
</tr>
<tr>
<th bgcolor="#FFFFFF" scope="row"><div align="left"><a href="VPinventoryviewraw.jsp">View</a></div></th>
</tr>
<tr>
<th scope="row">&nbsp;</th>
</tr>
<tr>
<th bgcolor="#000066" scope="row"><div align="left" class="style14">Invoice</div></th>
</tr>
<tr>
<th bgcolor="#FFFFFF" scope="row"><div align="left" class="style20"><a href="vpinventoryinvoice.jsp">View</a></div></th>
</tr>
<tr>
<th height="21" scope="row"><div align="left"></div></th>
</tr>
<tr>
<th bgcolor="#000066" scope="row"><div align="left" class="style14">Finished Goods</div></th>
</tr>
<tr>
<th bgcolor="#FFFFFF" scope="row"><div align="left" class="style20"><a href="vpinventoryfinished.jsp">View</a></div></th>
</tr>
</table>

</div>
<div class="style8" id="apDiv7"><strong>Username: RAMIREZ, MICHAEL</strong></div>
<div class="style9" id="apDiv4">Help | Log Out</div>
<div class="style10" id="apDiv8">Raw Materials &gt;&gt; View &gt;&gt; Update</div>
<div id="apDiv13">
<form method="post" action="checkupdateraw.jsp">
<table width="710" border="0">
<tr>
<th width="148" scope="col"><div align="left">Raw Material</div></th>
<td width="552" scope="col"><div align="left">

<select name="rawMaterial" id="select">
<option>Raw A</option>
<option>Raw B</option>
</select>

</div></td>
</tr>

<%
String rawMaterial = request.getParameter("rawMaterial");//gets the value in the textbox
%><%
try { String URL,query; Connection con; Statement stmt;
ResultSet rs;

URL = "jdbc:odbc:sysdev";
query = "select qty from raw where rawMaterial = '"+rawMaterial+"'";
//query = "call getAge(strName1)";

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection(URL,"","");
stmt = con.createStatement();
rs = stmt.executeQuery(query);
%>

<tr>
<td>Qty</td>
<td><%=rs.getString("qty") %></strong></td>
</tr>
<%

con.close();
}

catch(Exception ex)
{
System.out.println(ex.toString());
}
%>

<tr>
<th scope="row"><div align="left">Enter New Quantity</div></th>
<td
<div align="left">
<input type="text" name="qty" id="textfield" />
</div>
</td>
</tr>

<tr>
<th scope="row">
<div align="left">
<input type="submit" name="button" id="button" value="Update" />
<input type="submit" name="button2" id="button2" value="Cancel" />
</form>
</div>
</th>
<td><div align="left"></div></td>
</tr>
</table>
</div>
</body>
</html>

shyam
07-13-2008, 06:44 PM
did u try adding value attribute to your options?

sher_amf
07-14-2008, 05:43 AM
so how do you do that?

sher_amf
07-14-2008, 04:21 PM
http://i104.photobucket.com/albums/m188/sher_amf/raw.jpg

here is the concept everytime the red circle which indicates the raw material then qty would change according to the qty of raw material in the database

BubikolRamios
07-14-2008, 07:35 PM
consider using javascript, if not, this is merely a matter of sending parameter back to server, refreshing whole page, but I would not do it that way.


take a look at this:
http://www.java2s.com/Code/JavaScript/Form-Control/LinkedComboBoxoptionCountryprovince.htm

sher_amf
07-24-2008, 11:17 AM
is there other examples with same concept?

sher_amf
07-25-2008, 10:55 AM
can anyone help with this code?
when i select the drop down box i want the current qty textfield to have the value of the current qty in the database
what is the error in this code?


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Update Raw Materials</title>
<style type="text/css">
<!--
#apDiv1 {
position:absolute;
width:308px;
height:341px;
z-index:1;
left: 132px;
top: 152px;
background-color: #FFFFFF;
}
#apDiv2 {
position:absolute;
width:105px;
height:115px;
z-index:2;
left: 13px;
top: 14px;
}
#apDiv3 {
position:absolute;
width:230px;
height:399px;
z-index:3;
left: 787px;
top: 160px;
}
#Layer1 {
position:absolute;
width:200px;
height:115px;
z-index:4;
left: 125px;
top: 17px;
}
#Layer2 {
position:absolute;
width:863px;
height:287px;
z-index:5;
left: 146px;
top: 187px;
}
#Layer3 { position:absolute;
width:116px;
height:115px;
z-index:5;
top: 154px;
}
#apDiv4 {
position:absolute;
width:107px;
height:19px;
z-index:6;
top: 146px;
left: 886px;
}
body {
background-image: url(images/bgimage&#37;20copy.png);
background-repeat: no-repeat;
}
#apDiv5 { position:absolute;
width:74px;
height:24px;
z-index:9;
left: 919px;
top: 144px;
}
#apDiv {position:absolute;
width:200px;
height:21px;
z-index:8;
left: 124px;
top: 144px;
}
#apDiv6 {
position:absolute;
width:601px;
height:115px;
z-index:10;
left: 155px;
top: 222px;
}
#apDiv7 {
position:absolute;
width:252px;
height:24px;
z-index:5;
left: 151px;
top: 146px;
}
.style8 {
color: #FFFFFF;
font-family: Calibri;
}
.style9 {
color: #FFFFFF;
font-weight: bold;
font-family: Calibri;
}
#apDiv9 {
position:absolute;
width:135px;
height:236px;
z-index:10;
left: 2px;
top: 168px;
}
#apDiv8 {
position:absolute;
width:421px;
height:22px;
z-index:11;
left: 156px;
top: 180px;
}
.style10 {
font-size: 18px;
font-weight: bold;
font-family: Calibri;
}
.style11 {color: #000000}
.style13 {font-family: Calibri}
#apDiv10 {
position:absolute;
width:485px;
height:209px;
z-index:12;
left: 155px;
top: 225px;
}
#apDiv11 {
position:absolute;
width:200px;
height:115px;
z-index:12;
left: 154px;
top: 219px;
}
.style14 {color: #FFFFFF}
#apDiv12 {
position:absolute;
width:360px;
height:33px;
z-index:13;
left: 663px;
top: 175px;
}
#apDiv13 {
position:absolute;
width:200px;
height:115px;
z-index:12;
left: 157px;
top: 217px;
}
.style18 {color: #000066; }
.style20 {color: #0000FF}
-->
</style>
<script type="text/javascript">
function updateQuantity()
{
var RM=document.getElementById("RM");
document.getElementById("amp").value=RM.options[RM.selectedIndex].text;
<%
try { String URL,query; Connection con; Statement stmt;
ResultSet rs;

URL = "jdbc:odbc:sysdev";
query = "select qty from raw where rawMaterial = "+%>RM.options[RM.selectedIndex].text<%;
//query = "call getAge(strName1)";

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection(URL,"","");
stmt = con.createStatement();
rs = stmt.executeQuery(query);
if (rs.next())
{
%>document.getElementById("amp").value=<%=rs.getString("qty")%>;<%
}

con.close();
}

catch(Exception ex)
{
System.out.println(ex.toString());
}
%>
}
</script>
</head>
<%@ page import="java.sql.*"%>
<%@ page import="java.util.*"%>
<body>
<div class="style13" id="apDiv9">
<table width="135" border="0">
<tr>
<th bgcolor="#000099" scope="col"><div align="left"><span class="style14">Home</span></div></th>
</tr>
<tr>
<th bgcolor="#FFFFFF" scope="col"><div align="left"><span class="style20"><a href="VPinventory.jsp">Return</a></span></div></th>
</tr>
<tr>
<th scope="col">&nbsp;</th>
</tr>
<tr>
<th bgcolor="#000099" scope="col"><div align="left"><span class="style8">Raw Materials</span></div></th>
</tr>
<tr>
<th bgcolor="#FFFFFF" scope="row"><div align="left" class="style18"><a href="VPinventoryreceived.jsp">Add </a></div></th>
</tr>
<tr>
<th bgcolor="#FFFFFF" scope="row"><div align="left" class="style18"><a href="VPinventoryreorder.jsp">Re-Order</a></div></th>
</tr>
<tr>
<th bgcolor="#FFFFFF" scope="row"><div align="left" class="style20"><a href="vpinventoryupdateraw.jsp">Update</a></div></th>
</tr>
<tr>
<th bgcolor="#FFFFFF" scope="row"><div align="left"><a href="VPinventoryviewraw.jsp">View</a></div></th>
</tr>
<tr>
<th bgcolor="#FFFFFF" scope="row"><div align="left" class="style20"><a href="vpinventoryextraraw.jsp">Request</a></div></th>
</tr>
<tr>
<th scope="row">&nbsp;</th>
</tr>
<tr>
<th bgcolor="#000066" scope="row"><div align="left" class="style14">Invoice</div></th>
</tr>
<tr>
<th bgcolor="#FFFFFF" scope="row"><div align="left" class="style20"><a href="vpinventoryinvoice.jsp">View</a></div></th>
</tr>
<tr>
<th height="21" scope="row">&nbsp;</th>
</tr>
<tr>
<th height="21" bgcolor="#000066" scope="row"><div align="left" class="style14">Job Order </div></th>
</tr>
<tr>
<th height="21" bgcolor="#FFFFFF" scope="row"><div align="left"><span class="style20"><a href="vpinventoryrelease.jsp">View</a></span></div></th>
</tr>
<tr>
<th height="21" scope="row"><div align="left"></div></th>
</tr>
<tr>
<th bgcolor="#000066" scope="row"><div align="left" class="style14">Finished Goods</div></th>
</tr>
<tr>
<th bgcolor="#FFFFFF" scope="row"><div align="left" class="style20"><a href="vpinventoryfinished.jsp">View</a></div></th>
</tr>
</table>
<div align="left">
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
</div>
<p>&nbsp;</p>
</div>
<div class="style8" id="apDiv7"><strong>Username: RAMIREZ, MICHAEL</strong></div>
<div class="style9" id="apDiv4">Help | Log Out</div>
<div class="style10" id="apDiv8">Raw Materials &gt;&gt; View &gt;&gt; Update</div>
<div id="apDiv13">
<form method="post" action="checkupdateraw.jsp">
<table width="710" border="0">
<tr>
<th width="148" scope="col"><div align="left">Raw Material</div></th>
<td width="552" scope="col"><div align="left">

<select name="rawMaterial" id="RM" onchange="updateQuantity()">
<%
try { String URL,query; Connection con; Statement stmt;
ResultSet rs;
String nAge ="";
URL = "jdbc:odbc:sysdev";
query = "select rawMaterial from raw";
//query = "call getAge(strName1)";

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection(URL,"","");
stmt = con.createStatement();
rs = stmt.executeQuery(query);

while (rs.next())
{%>
<option><%= rs.getString("rawMaterial")%></option>
<%
}

con.close();
}

catch(Exception ex)
{
System.out.println(ex.toString());
}
%>
</select>

</div></td>
</tr>

<%
String rawMaterial = request.getParameter("rawMaterial");//gets the value in the textbox
%>

<tr>
<th><div align="left">Current Qty</div></th>
<td><p><input type ="text" id="amp" disabled=true></p></strong></td>
</tr>


<tr>
<th scope="row"><div align="left">Enter New Quantity</div></th>
<td
<div align="left">
<input type="text" name="qty" id="textfield" />
</div>
</td>
</tr>

<tr>
<th scope="row">
<div align="left">
<input type="submit" name="button" id="button" value="Update" />
<input type="submit" name="button2" id="button2" value="Cancel" />
</form>
</div>
</th>
<td><div align="left"></div></td>
</tr>
</table>
</div>
</body>
</html>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum