Home Answers Viewqa JSP-Servlet Fetched Record from database show into text field of html page

 
 


Sajal Singhal
Fetched Record from database show into text field of html page
2 Answer(s)      6 months and 5 days ago
Posted in : JSP-Servlet

hi, i have a database with field merchant_code, merchant_name, city, region,

and also have html page with all above mentioned field

i have submit 20 record from front end of html file to my database like that 001 sajal Noida North

002 suresh Kanpur East

003 Divest Delhi South

... ... ...

now my question is that

if i have a report page with same four above filed

and i type any letter in the text field of merchant name then suggest all merchant name in the form of drop down list like if i type s sajal Suresh

and on select any value rest of all three field display related value which i insert in the database

plz help me i have to submit my project

View Answers

November 21, 2012 at 3:04 PM


Here is a jsp code that display the records into textfields according to the id entered by user.

1)ajax.jsp:

<%@page import="java.sql.*"%>
<html>
<head>
<script type="text/javascript">
function showData(){ 
xmlHttp=GetXmlHttpObject()
    var id=document.getElementById("id").value;
var url="getdata.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("name").value= strar[1];
        document.getElementById("address").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>
<form >
<br><br>
<table >
<tr><td>Client ID:</td><td><input type="text" id="id" name="id" onkeyup="showData();"></td></tr>
<tr><td>Name:</td><td><input type="text" id="name" name="name"></td></tr>
<tr><td>Address:</td><td><input type="text" id="address" name="address"></td></tr>
</table>
</body>

2)getdata.jsp:

   <%@ page import="java.sql.*" %> 
    <%
    int id = Integer.parseInt(request.getParameter("id"));

     String data=" ";  
     try{
      Class.forName("com.mysql.jdbc.Driver");
               Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
     Statement stmt = con.createStatement();  
     ResultSet rs = stmt.executeQuery("Select * from addclients where clientid  ="+id+"");  
       while(rs.next())
                    {
                        data = ":" + rs.getString("name") + ": " + rs.getString("address");
                    }
                    out.println(data);
      }
     catch(Exception e){
    System.out.println(e);
     }

 %>
</html>

For more information, visit the following link:

http://www.roseindia.net/jsp/comboSelect.shtml


November 23, 2012 at 1:46 PM


Thanks Sir









Related Pages:
Fetched Record from database show into text field of html page
Fetched Record from database show into text field of html page  hi, i have a database with field merchant_code, merchant_name, city, region, and also have html page with all above mentioned field i have submit 20 record from
automatically move next page when data fetched from database is stored in text field
automatically move next page when data fetched from database is stored in text... are stored in database wherein when the in the first text field the data is already... from database and entered the next page should load without the user clicking
retrive record from the text field and insert into to database
retrive record from the text field and insert into to database  the following code is inserting values in the my sql database but i want to insert... ServletException,IOException{ response.setContentType("text/html
retrieve record from table and show it in HTML
retrieve record from table and show it in HTML  Hi. I have a field in database named stages. its datatype is varchar(60). It contains values chennai,trichy,kanchipuram for a single record. I have to retrieve these data from
retrieve record from the field table
retrieve record from the field table  Hi. I have a field in database...,kanchipuram for a single record. I have to retrieve these data from the field table... values like chennai as one value, trichy as one value. and i have to show it in html
Use of Select Box to show the data from database
from database This example will describe you the use of Select Box in a JSP page to show the data fetched from the database. We are using Servlet to get data... Use of Select Box to show the data from database   
HTML & MYSQL - retrieve record from table
HTML & MYSQL - retrieve record from table  Hi. I have a field in database named stages. its datatype is varchar(60). It contains values chennai,trichy,kanchipuram for a single record. I have to retrieve these data from the field
retrieve record from table
retrieve record from table  Hi. I have a field in database named... for a single record. I have to retrieve these data from the field table. Actually... chennai as one value, trichy as one value. and i have to show it in html. how
Show results in HTML
Show results in HTML  Hi. I have a field in database named stages... for a single record. I have to retrieve these data from the field table. Actually... as one value, trichy as one value. and i have to show it in html. how to do
Text Field in HTML
Text Field in HTML.In this Tutorial, the code create a text field in HTML page... Text Field in HTML       The Text Field in HTML are one line areas, which enable the user
Loading a jsp page (with record from database) from another jsp page
Loading a jsp page (with record from database) from another jsp page  ... with records from database(against Serial no and year).That is, as soon as Getdata.jsp will be loaded, it will show the first record. How can I do
How to retrieve record from table
How to retrieve record from table  Hi. I have a field in database...,kanchipuram for a single record. I have to retrieve these data from the field table... like chennai as one value, trichy as one value. and i have to show it in html
Acess Record from database.
Acess Record from database.  How to access records from database and how to display it on view page, with the help of hibernate
Inserting data from the HTML page to the database
Inserting data from the HTML page to the database... program in which we are going to insert the values in the database table from... the html will be set in the database by using the setString() method
How to Autogenerate of ID from database and show on JSP page?
How to Autogenerate of ID from database and show on JSP page?  ..." prefix="html"%><%@ page contentType="text/html;charset=windows-1252"%>..." content="text/html; charset=windows-1252"> <title>untitled<
How to Autogenerate of ID from database and show on JSP page?
How to Autogenerate of ID from database and show on JSP page?  ..." prefix="html"%><%@ page contentType="text/html;charset=windows-1252"%>..." content="text/html; charset=windows-1252"> <title>untitled<
How to Autogenerate of ID from database and show on JSP page?
How to Autogenerate of ID from database and show on JSP page?  ..." prefix="html"%><%@ page contentType="text/html;charset=windows-1252"%>..." content="text/html; charset=windows-1252"> <title>untitled<
How to Autogenerate of ID from database and show on JSP page?
How to Autogenerate of ID from database and show on JSP page?  ... uri="/WEB-INF/struts-html.tld" prefix="html"%><%@ page contentType="text...; <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
fetch record from MYsql table query
fetch record from MYsql table query  Hi. I have a field in database...,kanchipuram for a single record. I have to retrieve these data from the field table... values like chennai as one value, trichy as one value. and i have to show it in html
MYSQL retrieve record from Data table
MYSQL retrieve record from Data table  Hi. I have a field in database...,kanchipuram for a single record. I have to retrieve these data from the field... values like chennai as one value, trichy as one value. and i have to show
Show image and text on same jsp page
Show image and text on same jsp page  Hi all, I have to display image and text on the same jsp page. The text and image are both retrived from mysql database. The image is shown correctly on seperate jsp page but when shown
Show Hyperlink in HTML Page
Show Hyperlink in HTML Page   ... code show you a HTML page, that create a link to another page. The code begins... to connect from one page to another page of the web. The anchor (<a>...<
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. <
Password Field in HTML
illustrates a username and password text field. <form action> :The page... Password Field in HTML     ... displays asterisks or bullets instead of the characters. Password text field is same
fetch values from database into text field
fetch values from database into text field  please provide the example for fetching values from database into text field of table wth edit...;/td>"); the i am getting "rs.getString" in the text field also..  
fetch values from database into text field
fetch values from database into text field  please provide the example for fetching values from database into text field of table as if i am... "rs.getString" in the text field also..   import java.awt.*; import
regarding out put display in html text field
regarding out put display in html text field  how to dispaly the output coming from servlet in a particular text field of html
SEARCHING THE DATA FROM DATABASE AND DISPLAY THE SEARCHED DATA IN HTML PAGE
SEARCHING THE DATA FROM DATABASE AND DISPLAY THE SEARCHED DATA IN HTML PAGE  pls help me....in this i want to search books from the database...\htdocs\project\opac1.php on line 10 HERE IS MY CODE my html page is <
I have to retrieve these data from the field table
I have to retrieve these data from the field table  Hi. I have a field in database named stages. its datatype is varchar(60). It contains values chennai,trichy,kanchipuram for a single record. I have to retrieve these data from
delete record
deleted from the database. In the database we have created three fields bookid,author and title in the database. 1) Create book.jsp <%@page import="java.sql....delete record  how to delete record using checkbox and button in php
JSP Delete Record From Table Using MySQL
JSP Delete Record From Table Using MySQL This tutorial explains you that how to write a JSP for deleting a record from database table. In this section you.... In this tutorial you will learn that how to delete a record of a database table in JSP
how to display data from database according to entered value in search field
; <%@page import="java.sql.*"%> <%@page contentType="text/html...how to display data from database according to entered value in search... contentType="text/html" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C
JSP combo and text field related questio
JSP combo and text field related questio  in JSP,i had stored data from database in a textboxes usin combo..now i want to use these values of text... and name given to that text field..but its showing somethimng null pointer exception
add record to database - JDBC
add record to database  How to create program in java that can save record in database ?  Hi friend, import java.io.*; import java.sql....{ response.setContentType("text/html"); PrintWriter out = response.getWriter
Adding image to database through jsp or HTML page ,while adding only image should show.
Adding image to database through jsp or HTML page ,while adding only image should show.   Adding image to database through jsp or HTML page,while adding only image should show. After that i need view that uploaded image from
MySql Databse query to fetch results from database and display it in HTML File
MySql Databse query to fetch results from database and display it in HTML File  Hi. I have a field in database named stages. its datatype is varchar... to retrieve these data from the field table. Actually they are separated by comma
HTML
Field in HTML are one line areas, which enable the user to enter input text... as text field.    Paragraph in HTML...; tags.   Show Hyperlink in HTML Page HTML
How to show next question from database on the click of next button..(Struts & Hibernate)
How to show next question from database on the click of next button..(Struts... contentType="text/html"%> <%@page pageEncoding="UTF-8"%> <...; <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
How to show next question from database on the click of next button..(Struts & Hibernate)
How to show next question from database on the click of next button..(Struts... contentType="text/html"%> <%@page pageEncoding="UTF-8"%> <%@ taglib uri... http-equiv="Content-Type" content="text/html; charset=UTF-8"> <
retriving data from sql server using jsp code and placing them in text fields of html code
retriving data from sql server using jsp code and placing them in text fields of html code  Hi, my question is how to retrieve data from sql server 2008 using a jsp file and place the values in the text fields of a html file
text field
text field  How to retrieve data from text field   Hi Friend, Try the following code: import java.awt.*; import javax.swing.*; import java.awt.event.*; class RetrieveDataFromTextFields{ public static void main
ACCESS DATABASE FROM HTML
ACCESS DATABASE FROM HTML  I want to access sql 2008 database in html page without help of ADODB connection.. because if access through ADODB means there is a security problem. so, Access database in html page(client side
HTML
this field in form the data will be store into database.my database is the sql server... it shows as null. here is the html code for date of birth: <tr> <... addOption(selectbox,text,value ) { var optn = document.createElement("OPTION
Edit the record.
Edit the record.  sir, I have a table consist of huge data.I have... to previous edited row or edit the previous record of the previously edited... or some email.according to the sorted page we should fetch the data and edit
JSP to add details to a database from a HTML form.
JSP to add details to a database from a HTML form.  Hi I'm a second year CS student who has to use JSP to validate a HTML form and add the details...; <%@ page contentType = "text/html" %> <%@ taglib uri="http
How to retrive a particular record from database in php with mysql?
How to retrive a particular record from database in php with mysql?  Am using phpMyAdmin Database.In mysql database having 10 records. The field... record based on username and password. I dont know how to retrive in php with mysql
display data from a table in Access Database in a HTML page
display data from a table in Access Database in a HTML page  how to display data from a table in Access Database in a HTML page in a Java Program
instead of text boxe i have to show check box as selected.
instead of text boxe i have to show check box as selected.  i have one text field. in that iam getting boolean value either true or false from the database. when ever the valsue is there in textfield, instead of text boxe i
Calling Servlet to build a List of data from database and show this on the JSP page in table
Calling Servlet to build a List of data from database and show this on the JSP... to retrieve all the data from database and then add the data into list. The list... list from database and how it can be added to the request object and sent
centre text html
centre text html  centre text HTML - How to centre any field in HTML Page   <!DOCTYPE html> <html lang="de"> <head>...; html, body { height: 100%; margin: 0; padding

Ask Questions?

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.