autocomplete displaying multiple fields

Ads
 

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

Ads









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 data
displaying data   how to display data from database on jsp using struts2
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
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
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
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
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
(Displaying a calendar in GUI
(Displaying a calendar in GUI  (Displaying a calendar) Write a program that displays the calendar for the current month, as Use labels, and set texts on the labels to display the calendar."The Calendar and GregorianCalendar
Displaying date in the preciding code
Displaying date in the preciding code  while deploying the Bill date field on this page are empty though it should be displayed String userName = request.getParmeter("userName"); String custId = request.getParameter("customerId
multiple inheritance
multiple inheritance  why java doesn't support multiple inheritance? we can achieve this by using interface but not with classes? what is the main reason that java community implemented like
Version of com.mirzaakhena>swing-autocomplete dependency
List of Version of com.mirzaakhena>swing-autocomplete dependency
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
Displaying different portions of a page subsequently on the basis of action
Displaying different portions of a page subsequently on the basis of action  Suppose in Report.jsp there are two text fields From Date: and To Date: with js calender beside these and a SEARCH Button(When the page initially loads
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_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 '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 '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

Ads