autocomplete displaying multiple fields

autocomplete displaying multiple fields

How can I create an autocomplete with three field (name, id, phone). Placing the phone field in the appropriate input field but selecting the name field into the 'calling' input box?

View Answers

February 3, 2011 at 12:59 PM

Hi Friend,

Try this: 1)ajax.jsp:

<%@page import="java.sql.*"%>
<html>
<head>
<script type="text/javascript">
function showData(value){ 

xmlHttp=GetXmlHttpObject()
var url="getdata.jsp";
url=url+"?name="+value;
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(":");
    document.getElementById("address").value= strar[1];
    document.getElementById("contactNo").value= strar[2];
    document.getElementById("email").value= strar[3];
    } 
}
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 name="employee">
<br><br>
<table >
<div id="mydiv"></div>
   <tr><td><b>Name:</b></td><td> 
 <input  type="text" name="name" id="name" onkeyup="showData(this.value);"></td></tr>
<tr><td ><b>Address:</b></td><td>
<input  type="text" name="address" id="address" ></td></tr>
<tr><td><b>ContactNo:</b></td><td>
<input  type="text" name="contactNo" id="contactNo" ></td></tr>
<tr><td><b>Email:</b></td><td>
<input  type="text" name="email" id="email" ></td></tr>
</table>
</form>    
<table border="0" width="100%" align="center">
<br>
<br>
</table>
</body>
</html>

2)getdata.jsp:

<%@ page import="java.sql.*" %> 
<%
String name = request.getParameter("name").toString();
System.out.println(name);
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 employee where name='"+name+"'");
while(rs.next())
{
data =":"+rs.getString("address") + ":" + Integer.parseInt(rs.getString("contactNo"))+":"+rs.getString("email");
}


out.println(data);
System.out.println(data);
}
catch (Exception e) {
System.out.println(e);
}
%>

Thanks









Related Tutorials/Questions & Answers:
autocomplete displaying multiple fields
autocomplete displaying multiple fields  How can I create an autocomplete with three field (name, id, phone). Placing the phone field in the appropriate input field but selecting the name field into the 'calling' input box
multiple fields in hashtable
multiple fields in hashtable  Hai,could anyone help me to implement the object car fields speed,make & color in Hash table
Advertisements
Displaying the values in text fields of a form from a javascript function in jsp
Displaying the values in text fields of a form from a javascript function in jsp  Hi all, I have a requirement like this, First i have... to display these values in 3 text fields of a form in the current web page. Here form
autocomplete
autocomplete  I used autocomplete from roseindida.net.. i am getting the autocomplete is coming the retrieved values of database in the list..but when i select the value it is not displaying on the field.. and again i need
fields
fields  hi.create a class named librarybook that contains fields to hold methods for setting and getting a librarybooks title,author, and page count
Displaying images - JDBC
Displaying images  How to display multiple images on a single jsp from MySql database
Displaying images - JDBC
Displaying images  How to display multiple images on a single jsp from MySql database
Autocomplete demo
Autocomplete demo   Thanks for the autocomplete demo, it's working fine but results are showing in different fashion Please see attached image. Can some one help me
Autocomplete demo
Autocomplete demo   Thanks for the autocomplete demo, it's working fine but results are showing in different fashion Please see attached image. Can some one help me
displaying data
displaying data   how to display data from database on jsp using struts2
ModuleNotFoundError: No module named 'autocomplete'
ModuleNotFoundError: No module named 'autocomplete'  Hi, My Python... 'autocomplete' How to remove the ModuleNotFoundError: No module named 'autocomplete' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'autocomplete'
ModuleNotFoundError: No module named 'autocomplete'  Hi, My Python... 'autocomplete' How to remove the ModuleNotFoundError: No module named 'autocomplete' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'autocomplete'
ModuleNotFoundError: No module named 'autocomplete'  Hi, My Python... 'autocomplete' How to remove the ModuleNotFoundError: No module named 'autocomplete' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'autocomplete'
ModuleNotFoundError: No module named 'autocomplete'  Hi, My Python... 'autocomplete' How to remove the ModuleNotFoundError: No module named 'autocomplete' error? Thanks   Hi, In your python
CAPXOUS AutoComplete
CAPXOUS AutoComplete       CAPXOUS AutoComplete is an AJAX suggestion component. You may have already tasted this impressive feature on web sites like Google GMail or in business
Version of com.fifesoft>autocomplete dependency
List of Version of com.fifesoft>autocomplete dependency
Image is not displaying
Image is not displaying  Hii i am using spring javamail with html template to send mail,i am facing that image displaying prob when mail have to cm in gmail,in template just i am giving my current location of image which
displaying image
displaying image  how to upload image and retrieve it form database mysql in php?   Here is an example of uploading image using php. 1)form.html: <form method="post" enctype="multipart/form-data" action="upload.php
Autocomplete demo not working
Autocomplete demo not working  Hi Team, I am so happy with our examples on Autocomplete , http://www.roseindia.net/tutorial/jquery/autoComplete.html I have copied the source files to my local machine and renamed
PHP Displaying URL Content
PHP Displaying URL Content  In my PHP application form, on submitting the form details it always displaying url content. Can anyone tell me what is the reason and how to restrict it from displaying
Version of com.mirzaakhena>swing-autocomplete dependency
List of Version of com.mirzaakhena>swing-autocomplete dependency
codes for displaying in calendar
codes for displaying in calendar  can i get jsp codes for displaying comments, when the pointer is placed over the particular date in calendar
Autocomplete demo not working
Autocomplete demo not working  Hi Team, I am so happy with our examples on Autocomplete , http://www.roseindia.net/tutorial/jquery/autoComplete.html I have copied the source files to my local machine and renamed
ModuleNotFoundError: No module named 'appomatic_autocomplete'
ModuleNotFoundError: No module named 'appomatic_autocomplete'  Hi...: No module named 'appomatic_autocomplete' How to remove the ModuleNotFoundError: No module named 'appomatic_autocomplete' error? Thanks   Hi
ModuleNotFoundError: No module named 'appomatic_autocomplete'
ModuleNotFoundError: No module named 'appomatic_autocomplete'  Hi...: No module named 'appomatic_autocomplete' How to remove the ModuleNotFoundError: No module named 'appomatic_autocomplete' error? Thanks   Hi
ModuleNotFoundError: No module named 'appomatic_autocomplete'
ModuleNotFoundError: No module named 'appomatic_autocomplete'  Hi...: No module named 'appomatic_autocomplete' How to remove the ModuleNotFoundError: No module named 'appomatic_autocomplete' error? Thanks   Hi
ModuleNotFoundError: No module named 'appomatic_autocomplete'
ModuleNotFoundError: No module named 'appomatic_autocomplete'  Hi...: No module named 'appomatic_autocomplete' How to remove the ModuleNotFoundError: No module named 'appomatic_autocomplete' error? Thanks   Hi
ModuleNotFoundError: No module named 'autocomplete-richardshu'
ModuleNotFoundError: No module named 'autocomplete-richardshu'  Hi...: No module named 'autocomplete-richardshu' How to remove the ModuleNotFoundError: No module named 'autocomplete-richardshu' error? Thanks   
ModuleNotFoundError: No module named 'autocomplete_trie'
ModuleNotFoundError: No module named 'autocomplete_trie'  Hi, My... named 'autocomplete_trie' How to remove the ModuleNotFoundError: No module named 'autocomplete_trie' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'autocomplete_widget'
ModuleNotFoundError: No module named 'autocomplete_widget'  Hi, My... named 'autocomplete_widget' How to remove the ModuleNotFoundError: No module named 'autocomplete_widget' error? Thanks   Hi
ModuleNotFoundError: No module named 'autocomplete-yichunshi'
ModuleNotFoundError: No module named 'autocomplete-yichunshi'  Hi...: No module named 'autocomplete-yichunshi' How to remove the ModuleNotFoundError: No module named 'autocomplete-yichunshi' error? Thanks   Hi
ModuleNotFoundError: No module named 'fast-autocomplete'
ModuleNotFoundError: No module named 'fast-autocomplete'  Hi, My... named 'fast-autocomplete' How to remove the ModuleNotFoundError: No module named 'fast-autocomplete' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'irekua-autocomplete'
ModuleNotFoundError: No module named 'irekua-autocomplete'  Hi, My... named 'irekua-autocomplete' How to remove the ModuleNotFoundError: No module named 'irekua-autocomplete' error? Thanks   Hi
ModuleNotFoundError: No module named 'markov_autocomplete'
ModuleNotFoundError: No module named 'markov_autocomplete'  Hi, My... named 'markov_autocomplete' How to remove the ModuleNotFoundError: No module named 'markov_autocomplete' error? Thanks   Hi
ModuleNotFoundError: No module named 'wagtail-autocomplete'
ModuleNotFoundError: No module named 'wagtail-autocomplete'  Hi...: No module named 'wagtail-autocomplete' How to remove the ModuleNotFoundError: No module named 'wagtail-autocomplete' error? Thanks   Hi
ModuleNotFoundError: No module named 'appomatic_autocomplete'
ModuleNotFoundError: No module named 'appomatic_autocomplete'  Hi...: No module named 'appomatic_autocomplete' How to remove the ModuleNotFoundError: No module named 'appomatic_autocomplete' error? Thanks   Hi
ModuleNotFoundError: No module named 'autocomplete-richardshu'
ModuleNotFoundError: No module named 'autocomplete-richardshu'  Hi...: No module named 'autocomplete-richardshu' How to remove the ModuleNotFoundError: No module named 'autocomplete-richardshu' error? Thanks   
ModuleNotFoundError: No module named 'autocomplete_trie'
ModuleNotFoundError: No module named 'autocomplete_trie'  Hi, My... named 'autocomplete_trie' How to remove the ModuleNotFoundError: No module named 'autocomplete_trie' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'autocomplete_widget'
ModuleNotFoundError: No module named 'autocomplete_widget'  Hi, My... named 'autocomplete_widget' How to remove the ModuleNotFoundError: No module named 'autocomplete_widget' error? Thanks   Hi
ModuleNotFoundError: No module named 'autocomplete-yichunshi'
ModuleNotFoundError: No module named 'autocomplete-yichunshi'  Hi...: No module named 'autocomplete-yichunshi' How to remove the ModuleNotFoundError: No module named 'autocomplete-yichunshi' error? Thanks   Hi
ModuleNotFoundError: No module named 'django-autocomplete'
ModuleNotFoundError: No module named 'django-autocomplete'  Hi, My... named 'django-autocomplete' How to remove the ModuleNotFoundError: No module named 'django-autocomplete' error? Thanks   Hi
ModuleNotFoundError: No module named 'fast-autocomplete'
ModuleNotFoundError: No module named 'fast-autocomplete'  Hi, My... named 'fast-autocomplete' How to remove the ModuleNotFoundError: No module named 'fast-autocomplete' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'gunhojung-autocomplete'
ModuleNotFoundError: No module named 'gunhojung-autocomplete'  Hi...: No module named 'gunhojung-autocomplete' How to remove the ModuleNotFoundError: No module named 'gunhojung-autocomplete' error? Thanks   Hi
ModuleNotFoundError: No module named 'irekua-autocomplete'
ModuleNotFoundError: No module named 'irekua-autocomplete'  Hi, My... named 'irekua-autocomplete' How to remove the ModuleNotFoundError: No module named 'irekua-autocomplete' error? Thanks   Hi
ModuleNotFoundError: No module named 'jzhu-autocomplete'
ModuleNotFoundError: No module named 'jzhu-autocomplete'  Hi, My... named 'jzhu-autocomplete' How to remove the ModuleNotFoundError: No module named 'jzhu-autocomplete' error? Thanks   Hi, In your
Multiple implementaion of datepicker.
Multiple implementaion of datepicker.  Hello Sir I am using date-picker in my web page. But i need to put date-picker on multiple text fields without using different "id" for text fields. Please help me and give me some
image displaying in java
image displaying in java  how to display an image by using load image button in applet viewer
multiple inheritance.
multiple inheritance.  hello, can java support multiple inheritance???   hi,ADS_TO_REPLACE_1 java does not support multiple inheritance
upload image and fields.....fields is id name.....
upload image and fields.....fields is id name.....  Get Data using Java Servlet The frame takes following input.. Id: Name: browse:Image are file
upload image and fields.....fields is id name.....
upload image and fields.....fields is id name.....  Hi this is sreenu my problam is capcharing data to the servler thi is my frame Id: Name: browse:Image are file

Ads