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....









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
auto complete text box - Ajax
auto complete text box  How to create auto complete text box in jsp using ajax technology ? plz giv me steps wise code
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
Search word from text file using Java
How to Search word from text file using Java In this section, we are going to search a word from the text file. For this, we have created a swing button... void main(String[] args) { SearchName search = new SearchName(); JButton
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
jQuery auto complete through database using JSP In this tutorial, we will implement auto complete through database using JSP. In this example a text box is given, when you enter name of any Indian state , it will auto complete
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
Auto complete text box using jQuery plug in
Auto complete text box using jQuery  plug in In this tutorial, we will discuss about how to implement auto complete using jQuery plug in. In this example , a text box is given , where you have to enter any Indian state . When you
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
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
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
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
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
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
Java - search/find a word in a text file - Java Beginners
Java - search/find a word in a text file  Hello, I would like... to search them for a word. The word will be PASS or it can be FAIL. If PASS I...); System.out.print("Enter word to find: "); String word=input.next
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
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
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
Using poi hwpf,how to create table in word document. - Java Beginners
Using poi hwpf,how to create table in word document.  Can you please tell me how to create a table in the word document in java using Apache poi hwpf.its very urgent.Please send some sample code.Thanks in advance
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
using jsp's....and ajax - Ajax
using jsp's....and ajax  Hi, i need code using ajax .....in a text box when i enter an alphabet i should get list of words starts with the alphabet given in the text box
Auto Complete Text Box - JSP-Servlet
Auto Complete Text Box  Please help me in Aotocomplete text box code. I m a java programmer. I m working on jsp tech. please give me the code for Autocomplete text box in which the values will generate from database table
how to search a word on entire database? - SQL
how to search a word on entire database?  hi, I want to search a word into the entire database.. note: not from particular table.. using php and mysql. any way to find this? thanks in advance
Find Longest Word from the string using Java
Find Longest Word from the string using Java Here we are going to find the longest word from the string. For this, we have specified the string which... and allow the longest word to display. Here is the code
creation of drop down menu using ajax in java - Ajax
creation of drop down menu using ajax in java  Hi, Here I want to create a drop down menu using ajax in ofbiz framework. I want to fetch... any examples using ajax in java.so can you help? Regards, Padmashree
Ajax with java(using Dojo) - JSP-Servlet
Ajax with java (using Dojo)  Hi, In In place Edit Box,when I click "save" button how can I save the data in server side i.e JSP or how can I call.... Is there a possibility for tutorial on Scriptaculous. us,for Java programmers
Auto Complete Text Box - JSP-Servlet
Auto Complete Text Box - JSP-Servlet  Auto Complete Text Box Please help me in Aotocomplete text box code. I m a java programmer. I m working on jsp... stateChange(){ if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete
Login Form using Ajax
Login Form using Ajax      ... using the Ajax (DOJO).  Lets develop a login application using Ajax...; </action> Develop a Login Form Using Ajax : The GUI
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
auto suggest where the data should come from database - Ajax
auto suggest where the data should come from database  auto suggest in (java script or ajax)where the data should come from one of the table... the following link which contains an Auto completer example created in Struts
how to fetch the record using AJAX? - Ajax
how to fetch the record using AJAX?  Can anyone tell me how to fetch the records from database using Ajax

Ads