
Hi, our project involves fetching of data from database into textbox depending upon another textbox value which is productid.First the id entered by us will be checked to database weather it exist or not and if it exists the corresponding producttype and product_price should populate into textbox,which a user cannot modify.
Please provide the respective code..Waiting for your reply.

1)checkid.jsp:
<%@page import="java.sql.*"%>
<html>
<head>
<script type="text/javascript">
function showData(){
xmlHttp=GetXmlHttpObject()
var id=document.getElementById("id").value;
var url="id.jsp";
url=url+"?id="+id;
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null);
}
function stateChanged(){
if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){
var showdata = xmlHttp.responseText;
var strar = showdata.split(":");
if(strar.length>1){
var strname = strar[1];
document.getElementById("type").value= strar[1];
document.getElementById("price").value= strar[2];
}
}
}
function GetXmlHttpObject(){
var xmlHttp=null;
try{
xmlHttp=new XMLHttpRequest();
}
catch(e){
try{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e){
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
</script>
</head>
<body>
<br><br>
<table >
<tr><td>ID:</td><td><input type="text" id="id" name="id" onkeyup="showData();"></td></tr>
<tr><td>Product Type:</td><td><input type="text" id="type" name="name"></td></tr>
<tr><td>Price:</td><td><input type="text" id="price" name="address"></td></tr>
</table>
</body>
</html>
2)id.jsp:
<%@ page import="java.sql.*" %>
<%
String id = request.getParameter("id").toString();
System.out.println(id);
String data ="";
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from item where itemid='"+id+"'");
while(rs.next())
{
data = ":" + rs.getString("item") + ": " + rs.getString("price");
}
out.println(data);
System.out.println(data);
}
catch(Exception e) {
System.out.println(e);
}
%>

hi, great job. I have the same problem.plz help me.
I have MySQL DataBase/DB Name:lokesh;
Table Name:TR_list;
columns:nodename,packageno,TR;
Values(crs,cs 4.0,xxx),
Values(sdp,cs 5.0,yyy),
Values(air,cs 6.0,zzz),
i want to create a viewTR.jsp file in netbeans IDE,
where i have to :
1.connect to DB in MYSQL and
2.TR List:input Text Box and
i.e.,select nodename,packageno from TR_list where TR='xxx';
Plz help me
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.