Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet retrieving data from database to the textbox depending upon the id in jsp
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


niharika gupta
retrieving data from database to the textbox depending upon the id in jsp
2 Answer(s)      3 years and 6 months ago
Posted in : JSP-Servlet


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.


Advertisement
View Answers

July 4, 2011 at 11:29 AM


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);
}
%>


July 21, 2011 at 12:17 PM


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 button. 3.In the same viewTR.jsp file, i have to display the Nodename and packageno.

i.e.,select nodename,packageno from TR_list where TR='xxx';

Plz help me



Related Tutorials/Questions & Answers:
retrieving data from database to the textbox depending upon the id in jsp
retrieving data from database to the textbox depending upon the id in jsp  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
display data from database in textbox when id entered in textbox
display data from database in textbox when id entered in textbox  i wanted to enter data in textbox .depending on entered data in textbox data from database should be displayed dynamically in textbox
Advertisements
How to show data from database in textbox in jsp
How to show data from database in textbox in jsp   How to show data from database in textbox in jsp   Here is an example that retrieve the particular record from the database and display it in textbox using JSP. <
By dropdownlist retrive data from database and show in textbox in jsp.
By dropdownlist retrive data from database and show in textbox in jsp.  Hello Sir, I am doing project in jsp.I have to retrive data from database, when I select value from dropdownlist, and that data I want to show in textbox
Getting Textbox data from database
Getting Textbox data from database  When i m trying to get data in textbox as readonly from database i m getting following error.and my code is shown... data from database and display it on the textboxes. <%@page language="java
Getting Textbox data from database
;Here is a jsp code that retrieves data from database and display...Getting Textbox data from database  When i m trying to get data in textbox as readonly from database i m getting following error.and my code is shown
Retrieving Data from Database to fill Combo Box
Retrieving Data from Database to fill Combo Box  Sir, I have a JSP Page with a combo box and a label. I have a database that has two fields id... displaying path that is stored in the database but not the image itself. Kindly
The code for retrieving data from database into Drop Down List.
The code for retrieving data from database into Drop Down List.  <% DataSource data = new MysqlDataSource(); Connection con... but its now working.I am new to jsp, so dont know how to populate the textbox
retrieving of data from one jsp to another jsp - JSP-Servlet
retrieving of data from one jsp to another jsp  using jsp i m displaying a table ,in table i m displaying a radio button then values like id,name etc ,if i click on an radio button i have to get a corresponding id value
Retrieving data from data base using jsp combo box
Retrieving data from data base using jsp combo box  Hi guys please help me , i have on GUI page int that Server type(like apache,jboss,weblogic) one... of the server it has to display the process name from database into the process name
Connecting to MySQL database and retrieving and displaying data in JSP page
Connecting to MySQL database and retrieving and displaying data in JSP page...; This tutorial shows you how to connect to MySQL database and retrieve the data from the database. In this example we will use tomcat version 4.0.3 to run our
select value from autocomplete textbox using jquery in jsp from database.
select value from autocomplete textbox using jquery in jsp from database. ... but was unable to find out exact way to fullfill the solution of selecting value from autocomplete textbox using jquery in jsp from mysql database. Kindly send me
select value from autocomplete textbox using jquery in jsp from database.
select value from autocomplete textbox using jquery in jsp from database.  Hii Sir, Lots of thnx to ur reply .I went through both... of selecting value from autocomplete textbox using jquery in jsp from mysql database
how to check dates while retrieving data from database
how to check dates while retrieving data from database  i want to update database record based on delivery date i have tried this query but it wont work b="update deliveryorder set prtnm='"+arr[1]+"',stn='"+arr[0]+"',sbston
retrieving data in to the dropdown box from postgresql database in core java
retrieving data in to the dropdown box from postgresql database in core...=st.executeQuery("SELECT role_name from role WHERE dept_id=1234"); if(rs...) { JOptionPane.showMessageDialog(this, "The generated Id is:"); dispose
retrieving newly added records from mssql database and display in a jsp
retrieving newly added records from mssql database and display in a jsp ... from mssql database table and display those records in a jsp.And i have to delete these 10 records from the jsp and retrieve the next recently added 10 records
How to insert data from a combobox and textbox values into DB using JSP?
How to insert data from a combobox and textbox values into DB using JSP?  hi, How to insert a comb-box and a text box values in to DB using JSP? @DB:student; @table:stu_info; Combobox values:(class1,class2,class3); textbox1
related retrieving value from oracle database
related retrieving value from oracle database  how we get the value from database in the given textbox
related retrieving value from oracle database
related retrieving value from oracle database  how we get the value from database in the given textbox
retrieving xml document from database
retrieving xml document from database  Hi Guys, I want to retrieve the xml document stored in the database on to a jsp page using jdbc/odbc connnection.Please help me in implementing this feature. Thank You Madhu
how to make a radiobutton selected when retrieving data from database using struts framework and spring jdbc
how to make a radiobutton selected when retrieving data from database using struts framework and spring jdbc  how to make a radio button selected when retrieving data from database using struts framework and spring jdbc
retrieving from oracle database using jsp combo box
retrieving from oracle database using jsp combo box  hi this is my... name of the server has to display in the process name field from the oracle database please help on this i need code using servlets please help me . <
Retrieving JTree structure from database
the steps required to create tree retrieving the data from the database. Here... Retrieving JTree structure from database       This example shows how to retrieving data from
retrieving from db - JSP-Servlet
; Hi Retrive value from database Retrive data from database User id: Course Name Courese Fee...retrieving from db  hello' I am trying to write my first application
Dynamically Update textbox from database
Dynamically Update textbox from database  I have a database as shown below.(database created using SQL Server 2005) name : george,simon address... to that typed value from database has to be displayed in another text box
Retrieving specific data from excel
Retrieving specific data from excel  Hello everyone, i have written a simple code to retrieve data from excel sheet and working fine, the excel file... first sheet from the workbook HSSFSheet sheet = workbook.getSheetAt(0
How to Autogenerate of ID from database and show on JSP page?
How to Autogenerate of ID from database and show on JSP page?  ... tasks id as primay key, I am using JSP and struts for database connectivity,Now I can update my database but i want to autogenerate tasks id in numbers(ie
How to Autogenerate of ID from database and show on JSP page?
How to Autogenerate of ID from database and show on JSP page?  ... tasks id as primay key, I am using JSP and struts for database connectivity,Now I can update my database but i want to autogenerate tasks id in numbers(ie
How to Autogenerate of ID from database and show on JSP page?
How to Autogenerate of ID from database and show on JSP page?  ... tasks id as primay key, I am using JSP and struts for database connectivity,Now I can update my database but i want to autogenerate tasks id in numbers(ie
How to Autogenerate of ID from database and show on JSP page?
How to Autogenerate of ID from database and show on JSP page?  ... tasks id as primay key, I am using JSP and struts for database connectivity,Now I can update my database but i want to autogenerate tasks id in numbers on JSP
how to retreive values from MS Access Database based on the values entered in textbox values in jsp file
Solution field from database and display in the textbox of the jsp.   1... * from item where itemid='"+id+"'"); while(rs.next()) { data = ":" + rs.getString...how to retreive values from MS Access Database based on the values entered
Advertisements
 

 

 

DMCA.com