Auto complete of word search using ajax with java

Auto complete of word search using ajax with java

I want to display the list of words when I type the first letter of the word in a text box. I am using jsp to design the form. I want ajax sample to achieve this feature. Its like google search. Please help. Thanks in advance.

View Answers

March 12, 2011 at 11:36 AM

JSP Ajax Autocomplete box

1)autocomplete.jsp:

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

xmlHttp=GetXmlHttpObject()
var url="auto.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; 
    document.getElementById("mydiv").innerHTML= showdata;
    } 
}
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">
<input  type="text" name="name" id="name" onkeyup="showData(this.value);"><br>
<div id="mydiv"></div>

</table>
</body>
</html>

2)auto.jsp:

<%@ page import="java.sql.*" %> 
<%

String name = request.getParameter("name").toString();
String buffer="<div>";  
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 data where name like '"+name+"%'");
while(rs.next())
{
buffer=buffer+rs.getString("name")+"<br>";
}
buffer=buffer+"</div>";  
response.getWriter().println(buffer);
}
catch (Exception e) {
System.out.println(e);
}
%>

March 20, 2012 at 12:09 PM

hi,

i tried the same code above.

it is displaying the data.

but how can i click and select a specific data from the list? somebody pls help me..


April 1, 2013 at 1:26 PM

thats rite the objective is still not completed , i also want to select the data in textbox when i click on the items coming after search.........plz help thanks


February 6, 2014 at 8:04 AM

Did you guys found any solution for the above.....Even I am looking for the same , please help....

Ads









Related Tutorials/Questions & Answers:
Auto complete of word search using ajax with java
Auto complete of word search using ajax with java  I want to display the list of words when I type the first letter of the word in a text box. I am using jsp to design the form. I want ajax sample to achieve this feature. Its
Auto complete of word search using ajax with java
Auto complete of word search using ajax with java  I want to display the list of words when I type the first letter of the word in a text box. I am using jsp to design the form. I want ajax sample to achieve this feature. Its
Advertisements
Auto Search box using ajax
Auto Search box using ajax   Hi , i want to implement auto search box functionality like google and linkedin using ajax,jsp,servlet, javascript... this is possible in java. rahul   hi, Please go through the link, may
Ajax Auto Complete Tutorial
Auto Complete Example The auto complete feature helps the user to input the data correctly and quickly while submitting the form. An example of auto complete with JQuery is given below, to run this example you need to import two
How to perform search using AJAX?
How to perform search using AJAX?  Hi, I have following HTML code... and hit button, there is a Ajax call to retrieve search results from a simple txt...; <td><label for="status">Search Status</td> <td><input
jQuery auto complete through database using JSP shows error
jQuery auto complete through database using JSP shows error  The tutorial on jQuery titled "jQuery auto complete through database using JSP" shows error on browser when I try to select the one in the dropdown. Please help
How to merge two word document using java
How to merge two word document using java   how to merge two word document using java
How to merge two word document using java
How to merge two word document using java   how to merge two word document using java
convert date month and year into word using java
convert date month and year into word using java  convert the date...;continue.... public void pass(int number) { int word, q...; if (word == 0) { q = number / 10
convert date month and year into word using java
convert date month and year into word using java  convert the date...;continue.... public void pass(int number) { int word, q...; if (word == 0) { q = number / 10
convert date month and year into word using java
convert date month and year into word using java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
convert date month and year into word using java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
convert date month and year into word using java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
JSF Search Application Using Ajax
JSF Search Application Using Ajax     ... using Ajax. This is a simple application in which, you will see two JSF.... This application here using JSF and AJAX technology that mean this is based on the JSF
how to translate english word to marathi using java
how to translate english word to marathi using java  I want to translat english word to marathi,how i can develop a code for that ,please sajest me
convert date month and year into word using java
Java Date Month Format  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
convert date month and year  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
convert date month and year Java  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Match Date format  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Basic format for Date and Month  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Convert Date Format  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Date Format in Jave  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
convert date month and year into word using java
Convert Date Month format  convert the date, month,year into word like 12-3-2012 into twelve march two thousands twelve pls send the code write in java.   Visit Here
Using Ajax
Using Ajax  Hi, How I can use Ajax in web programming? Tell me any example which using Ajax to call server side script? Thanks   Hi, Here are examples: PHP Ajax and Database First Ajax Example Getting Started
Merge multiple jasper file to one word Doc using java
Merge multiple jasper file to one word Doc using java   how to Merge multiple jasper file to one word Doc using java
AJAX Search
using PHP and MYSQL as the database. Can somebody please suggest me the AJAX...AJAX Search  I have to create a project where the user enters...://www.roseindia.net/tutorial/ajax/jquery/autocomplete.html   continue
click a word and search it from a file
click a word and search it from a file  i want to link a word with a file and search it form the file by clicking it. what could the code for this process
Edit word document Headers and Footers using POI Library in java?
Edit word document Headers and Footers using POI Library in java?  Hi All, I need code to modify the Header and Footer contents of a ms-word template using POI or JACOB libraries. Could any one help me? Thanks Advance
ModuleNotFoundError: No module named 'word-search'
ModuleNotFoundError: No module named 'word-search'  Hi, My Python... 'word-search' How to remove the ModuleNotFoundError: No module named 'word-search' error? Thanks   Hi, In your python environment
ModuleNotFoundError: No module named 'word-search'
ModuleNotFoundError: No module named 'word-search'  Hi, My Python... 'word-search' How to remove the ModuleNotFoundError: No module named 'word-search' error? Thanks   Hi, In your python environment
Java search word from text file
Java search word from text file In this tutorial, you will learn how to search a word from text file and display data related to that word. Here, we have.... It then scan the whole file to search the name and display the id and marks
ModuleNotFoundError: No module named 'word-search-puzzle'
ModuleNotFoundError: No module named 'word-search-puzzle'  Hi, My... named 'word-search-puzzle' How to remove the ModuleNotFoundError: No module named 'word-search-puzzle' error? Thanks   Hi, In your
Creating Auto Shape in PowerPoint Using Java
Creating Auto Shape in PowerPoint Using Java... to create auto shape on PowerPoint slide using java. In this example, we... are using setAnchor() method to give the position of the shape. To fill
How to using Binary Search Array Java ?
How to using Binary Search Array Java ?  Hi, I am beginners in Java... functions. The problem is that how to use binary search array in Java. Please give any online reference show that i will implement the binary search array in Java
Ajax using jsp
Ajax using jsp  <%@ page import="java.io.*" %> <%@ page import="java.util.*" %> <%@ page import="java.sql.*" %> <%@ page import...); } %> Is there Any error...........In first Page I use ajax for displaying
ajax using jsp
ajax using jsp  <%@ page import="java.io.*" %> <%@ page import="java.util.*" %> <%@ page import="java.sql.*" %> <%@ page import="java.util.StringTokenizer" %> <%@ page import="java.lang.*" %> <
About search and replace contains of .doc or .docx file using java.
About search and replace contains of .doc or .docx file using java.  ... any one tell me how could I replace them using java... format but I am unable to do it. For example word document contains name
ModuleNotFoundError: No module named 'django-ajax-search'
ModuleNotFoundError: No module named 'django-ajax-search'  Hi, My... named 'django-ajax-search' How to remove the ModuleNotFoundError: No module named 'django-ajax-search' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'django-ajax-search'
ModuleNotFoundError: No module named 'django-ajax-search'  Hi, My... named 'django-ajax-search' How to remove the ModuleNotFoundError: No module named 'django-ajax-search' error? Thanks   Hi, In your
Search string using substring
Search string using substring  I want to print a string by searching a substring of that string. - i want to print email-ids from word files (resumes) in a directory. Search can be made using @ in the word file. So far i can
Hiding form values using ajax
Hiding form values using ajax  i am trying to show and hide form values with ajax but it's not working,but in javascript it is working.Can anyone will help me to the work in ajax please. Thanks in advance
Hibernate Search - Complete tutorial on Hibernate Search
Hibernate Search - Complete tutorial on Hibernate Search... search engine based on Hibernate Search. Developing Search Engines in Java... you can develop your own search engine for your website in Java
String file in to word file in java
String file in to word file in java  how to convert a String format word file into Ms Word file using java? please can anyone of you help me
application using AJAX and JQuery and also use JSP
application using AJAX and JQuery and also use JSP   i need create an application using AJAX and JQuery and also use JSP
Java Word Processor
Java Word Processor  Problem: Design and implement a class called...: ? You can break up a String into words or "tokens" by using java?s Scanner... of words (a hyphenated word is one word), o number of sentences (ends
ajax programming
This section contains the auto complete feature of Ajax. Ajax MySql Database... is based on the HTML, Java Script, CSS, and XML. Why Ajax Programming? When you... it is done using Ajax. When you enter the value in the input box and highlight to other
Java code to convert pdf file to word file
Java code to convert pdf file to word file  How to convert pdf file to word file using Java
String file in to word file in java
String file in to word file in java  How to convert a String format notepad file into Ms word file in java
Auto grow Text Area using jQuery plug-in
Auto grow Text Area using jQuery plug-in  Hi sir How can we make a textarea auto grow ? What is the name of the plug-in used for auto grow text area. Please mention code with your reply
program to display frequency count of each word in a file using Hashmap, Hashset and streamtokenizer.plz help me out ..
program to display frequency count of each word in a file using Hashmap...) { System.out.println("Enter word to search in given file(to stop words...:first=java) and store in HashMap and read the values from HashMap and search

Ads