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 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
Ads
Related Tutorials/Questions & Answers:
Advertisements
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
 
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
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..  
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
Fetching database field from servlet to jsp page ?
Fetching
database field from servlet to jsp
page ? Hello Java...
field.
I wanted to pass some of the
database field from servlet to jsp...
(i...="java.util.List"%>
<%@
page language="java" contentType="
text/
html
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
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
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
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
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>...<