in a text box and click on update button. once the button is click a function with parameter as the changed value. it is sent to a jsp file for updation.
when i try to run this code, it shows number format exception-input string undefined.
3 3819 Dormilich 8,658
Recognized Expert Moderator Expert
well, then you probably didn’t pass the value correctly somewhere.
but i could not find the error. been trying for long..
here s d code - <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-
<html>
-
<head>
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
-
<title>Untitled Document</title>
-
<%
-
// String id1=(String)session.getAttribute("user");
-
// out.println("welcome "+id1+",ur shopping cart contains");
-
%>
-
-
<%!
-
String p,pn,c,q;
-
%>
-
<SCRIPT language="javascript">
-
var xmlHttp,url;
-
-
-
-
function change1(p,val) //to check product availability and if available update the product table
-
{
-
// var d=window.document.getElementById("quantity");
-
// var n=d.options[d.selectedIndex].value;
-
xmlHttp=GetXmlHttpObject();
-
if (xmlHttp==null)
-
{
-
alert ("Your browser does not support AJAX!");
-
return;
-
}
-
url="https://localhost:8443/change.jsp";
-
-
// url=url+"?pwd="+n1+"&repwd="+n2;
-
-
-
url=url+"?prod="+p+"&q="+val;
-
xmlHttp.onreadystatechange=stateChanged;
-
xmlHttp.open("GET",url,true);
-
xmlHttp.send(null);
-
}
-
-
-
function stateChanged()
-
{
-
-
if(xmlHttp.readyState==4)
-
{
-
document.getElementById("dataTable").innerHTML=xmlHttp.responseText;
-
}
-
}
-
-
-
function GetXmlHttpObject()
-
{
-
if (window.XMLHttpRequest)
-
{
-
// code for IE7+, Firefox, Chrome, Opera, Safari
-
return new XMLHttpRequest();
-
}
-
if (window.ActiveXObject)
-
{
-
// code for IE6, IE5
-
return new ActiveXObject("Microsoft.XMLHTTP");
-
}
-
return null;
-
}
-
-
</SCRIPT>
-
</head>
-
<body>
-
-
<%
-
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
-
Connection con=DriverManager.getConnection("jdbc:odbc:ds");
-
-
Statement st = con.createStatement();
-
-
String q="SELECT * FROM \"ADMINISTRATOR\".USERID";
-
ResultSet rs=st.executeQuery(q);
-
%>
-
-
<form name="formId" action="tot1.jsp" method="post">
-
<table id="dataTable" border=2 bgcolor="#FFFFFF" cellpadding="5" cellspacing="2">
-
-
<tr>
-
<TH>CHOOSE</TH>
-
<th>PRODUCT ID</th>
-
<th>PRODUCT NAME</th>
-
<TH>COST</TH>
-
<TH>QUANTITY</TH>
-
</tr>
-
<%
-
while(rs.next())
-
{
-
-
p=rs.getString("PID");
-
pn=rs.getString("PNAME");
-
c=rs.getString("COST");
-
-
%>
-
-
<tr>
-
<td><input type="checkbox" name="uid" id="uid" value="<%= p%>" /></td>
-
<td ><%=p%> </td>
-
<td ><%=pn%> </td>
-
<td ><%=c%> </td>
-
-
<td><input type="text" name="quantity" id="quantity" value="1" /></td>
-
-
</td>
-
</tr>
-
-
<%
-
}
-
%>
-
-
<tr>
-
<td><input type="button" name="update" value="Update cart" onClick="change1(document.formId.uid.value,document.formId.quantity.value)"
-
</td>
-
<td><input type="button" name="add" value="Add more" onClick="window.location='http://localhost:8443/index2.jsp' " />
-
</td>
-
<td><input type="submit" name="submit" value="Checkout" />
-
</td>
-
</tr>
-
</table>
-
</form>
-
-
<%
-
st.close();
-
con.close();
-
%>
-
</body>
-
</html>
here s the jsp file to which the parameter is sent - <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
-
<%@ page import="java.io.*" %>
-
<%@ page import="java.lang.*" %>
-
-
<html xmlns="http://www.w3.org/1999/xhtml">
-
<head>
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
-
<title>Untitled Document</title>
-
</head>
-
<%!
-
String p,pn,c,sql,s1;
-
String update,update1;
-
int quantity;
-
%>
-
-
<body>
-
-
<%
-
String code=new String(request.getParameter("prod"));
-
String q=new String(request.getParameter("q"));
-
-
-
int ID=Integer.parseInt(code);
-
int qu=Integer.parseInt(q);
-
-
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
-
-
Connection con =DriverManager.getConnection("jdbc:odbc:ds");
-
Connection con1 =DriverManager.getConnection("jdbc:odbc:ds");
-
Connection con2 =DriverManager.getConnection("jdbc:odbc:ds");
-
Connection con3 =DriverManager.getConnection("jdbc:odbc:ds");
-
-
-
Statement stmt=con.createStatement();
-
Statement stmt1=con1.createStatement();
-
Statement stmt2=con2.createStatement();
-
Statement stmt3=con3.createStatement();
-
-
-
s1="SELECT * FROM ADMINISTRATOR.PRODUCT WHERE PID="+ID;
-
ResultSet rs=stmt1.executeQuery(s1);
-
-
while(rs.next())
-
{
-
p=rs.getString("quantity");
-
quantity=Integer.parseInt(p);
-
-
if(qu<quantity)
-
{
-
quantity=quantity-qu;
-
-
-
sql = "UPDATE ADMINISTRATOR.USERID SET QUANTITY="+qu+" WHERE PID= "+ID;
-
stmt.executeUpdate(sql);
-
-
update="UPDATE ADMINISTRATOR.PRODUCT SET QUANTITY="+quantity+" WHERE PID="+ID;
-
stmt1.executeUpdate(update);
-
-
update1="UPDATE ADMINISTRATOR.PROD SET QUANTITY="+quantity+" WHERE PID="+ID;
-
stmt2.executeUpdate(update1);
-
-
}
-
-
else if(qu>quantity)
-
{
-
// response.sendRedirect("https://localhost:8443/index1.jsp");
-
out.print(" REQUIRED QUANTITY NOT AVAILABLE");
-
}
-
}
-
stmt.close();
-
stmt1.close();
-
stmt2.close();
-
stmt3.close();
-
-
con.close();
-
con1.close();
-
con2.close();
-
con3.close();
-
-
%>
-
</body>
-
</html>
acoder 16,027
Recognized Expert Moderator MVP
When passing any URL parameters, encode them using encodeURIComponent().
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: junglist |
last post by:
Hi guys,
I've been trying to implement an editable datagrid and i have been
succesful up to the point where i can update my datagrid row by row.
However what used to happen was that once i updated...
|
by: ransoma22 |
last post by:
I developing an application that receive SMS from a connected GSM
handphone, e.g Siemens M55, Nokia 6230,etc through the data cable.
The application(VB.NET) will receive the SMS automatically,...
|
by: ggk517 |
last post by:
We are trying to develop an Engineering application using PHP,
Javascript with Informix as the back-end.
Is it possible to retrieve data using Javascript but by accessing the
Database. Say...
|
by: Serge Rielau |
last post by:
Hi all,
Following Ian's passionate postings on problems with ALTOBJ and the
alter table wizard in the control center I'll try to explain how to use
ALTOBJ with this thread. I'm not going to get...
|
by: =?Utf-8?B?RGVlcGE=?= |
last post by:
Hi All,
I have a webform in asp.net framework 1.1 where the dropdownlist is
populated with list of locations from the database. The depending on the list
selected, the user will be able to see...
| |
by: shivendravikramsingh |
last post by:
hi friends, i m using a ajax function for retrieving some values from a database table,and display the values in required field,my prob is that the ajax function i m using is working f9 once,but if...
|
by: Shalini Bhalla |
last post by:
i have 2 tables bank master and branch details having bankcode as a common feild .
i have designed a form in which i am filtering branches according to a particular bank code using ajax ,...
|
by: JDOMPer |
last post by:
Don’t misunderstand me – I use AJAX, but I think there is a far simpler, elegant alternative that just uses Javascript, the DOM and Php ( hence - JDOMP) for data transfers, and is cross-browser...
|
by: javediq143 |
last post by:
Hi All,
This is my first post in this forum. I'm developing a CMS for my latest website. This CMS is also in PhP & MySQL. I'm done with the ADD section where the Admin can INSERT new records in...
|
by: thatcollegeguy |
last post by:
Below are my 3php and 2js files.
I create a table using ajax/php and then want to change the values in the tables add(+ number for teamid) id's for each specific td in the table. I don't know...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| | |