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



Home Answers Viewqa JavaScriptQuestions autocomplete displaying multiple fields
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Hugh
autocomplete displaying multiple fields
1 Answer(s)      3 years and 8 months ago
Posted in : JavaScript Questions


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?


Advertisement
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
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
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
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
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
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
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
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
jQuery autocomplete with jsonp
jQuery autocomplete with jsonp  Im trying to develope an autocomplete script using jQuery, now Im in the last step. I need to make a php page... to autocomplete)should lok like. I know the script using something call "jsonp
jQuery UI Widget : Autocomplete
jQuery UI Widget : Autocomplete       Query UI Widget : Autocomplete Using autocomplete widget , you can add autocomplete feature to your input 
is it possible to add a button inside an autocomplete jquery ui plugin?
is it possible to add a button inside an autocomplete jquery ui plugin?  is it possible to add a button inside an autocomplete jquery ui plugin? My requirement: I have a 4 text input fields that I want to implement autocomplete
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
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
displaying data
displaying data   how to display data from database on jsp using struts2
jQuery autocomplete
jQuery Autocomplete : Autocomplete is a common feature available in lot of web tools and services now a days. We see many of websites uses this feature of jquery. This example shows A function for making autocomplete text box
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
dhtmlxCombo - Ajax Autocomplete Combobox
dhtmlxCombo - Ajax Autocomplete Combobox   ... combo box with Ajax support. It is easy to configure. It also have autocomplete.... Filtering mode 6. Autocomplete mode 7. Editable mode   Four modes:  
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
jQuery Autocomplete fetch_object fatal error?
jQuery Autocomplete fetch_object fatal error?  I am consistently... of Jquery Autocomplete box. <script> $(function() { var...", "Scheme" ]; $( "#tags" ).autocomplete({ source
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 textbox with database in jsp and follow the MVC model
Autocomplete textbox with database in jsp and follow the MVC model  i have one problem in my project i try to generate the autocomplete textbox...... Thanks in advance  Here is a jsp code that shows autocomplete box
Javascript Code for all fields
Javascript Code for all fields  Good Evening Sir/Madam, Please send me the example program using bootstrap framework for all fields of a form. Please send me the javascript code My E-mail id: siva.ssk83@gmail.com Regards, S
Generating dynamic fields in struts2
Generating dynamic fields in struts2  Hi, I want generate a web page which should have have some struts 2 tags in a group and a "[+]" button for the group. On click of this button one more group of fields should be generated
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
how to add fields at runtime in j2me
how to add fields at runtime in j2me  How can I add fields at runtime in my form? How can I switch screens and can add fields at runtime? Thanks Dhruv
select value from autocomplete textbox using jquery in jsp from database.
select value from autocomplete textbox using jquery in jsp from database.  Sir, Lots of thnx to ur reply .I went through both the tutorials... autocomplete textbox using jquery in jsp from mysql database. Kindly send me
Advertisements
 

 

 

DMCA.com