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 tech. please give me the code for Autocomplete text box in which the values will generate from database table

View Answers

October 28, 2010 at 10:38 AM

Hi Friend,

Try the following code:

1)auto.jsp:

<%@page import="java.sql.*"%>
 <html>
 <head>  
 <script language="javascript" type="text/javascript">  
 var xmlHttp  
 var xmlHttp
 function showState(str){ 
if (typeof XMLHttpRequest != "undefined"){
   xmlHttp= new XMLHttpRequest();
       }
       else if (window.ActiveXObject){
   xmlHttp= new ActiveXObject("Microsoft.XMLHTTP");
       }
if (xmlHttp==null){
    alert ("Browser does not support XMLHTTP Request")
return
} 
var url="get.jsp";
url += "?count=" +str;
xmlHttp.onreadystatechange = stateChange;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}
 function stateChange(){   
 if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){   
 document.getElementById("country").innerHTML=xmlHttp.responseText;  
 }   
 }   
 </script>  
 </head>  
 <body>  
 <input id="name" type="text" name="name" onkeyup="showState(this.value)">
 <br>  
 <div id='country'>  
 </div>  
 </body> 
 </html>

2)get.jsp:

<%@page language="java" import ="java.sql.*" %>  
 <%  
 String name=request.getParameter("count");  
 String buffer="<div>";  
 Class.forName("com.mysql.jdbc.Driver").newInstance();  
 Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","root");  
 Statement stmt = con.createStatement();  
 ResultSet rs = stmt.executeQuery("Select * from country where countryname LIKE '"+name+"%'");  
   while(rs.next()){
   buffer=buffer+rs.getString(2)+"<br>";  
   }  
 buffer=buffer+"</div>";  
 response.getWriter().println(buffer);  
 %>

Hope that it works! Thanks


February 23, 2011 at 4:13 PM

how to use another executeQuery in the same page get.jsp.So that i can to fill data in another textbox or listbox


April 4, 2012 at 10:37 AM

Thanks Buddy its working Cool


April 1, 2013 at 2:55 PM

yeah thats working fine but it is just taking data in the textbox from the database but we are not able to select the data from textfield so object is not completed.How can we select the data into the textfield.









Related Tutorials/Questions & Answers:
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
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
Advertisements
radio button selection should move the control to a text box that needs to be complete
radio button selection should move the control to a text box that needs to be complete  on selection of a radio button mouse should move to a particular text box that needs to be filled. How
Is it any code available for auto suggest text box using do? - Development process
Is it any code available for auto suggest text box using do?  In dojo, we are having combo box, in which auto suggestion already implemented. Like that is it we have auto suggestion for text box
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
select box and text box validations
select box and text box validations  hi, any one please tell me how to set validations for select box and text boxes using bean classes? thank you   Please visit the following link: http://www.roseindia.net/jsp/user
Text box Checking
Text box Checking  I want to Write only the word A-Z in a text box What is the code
two text box problem
two text box problem  i have two text box in two different pages and same variable use in two text box when enter value in first text box it's reflection show in second text box , how i reduce it in jsf ?   Hi Friend
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
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
java script text box
will click submit button the text should be submitted(it shows the value in alert). i also want the text box should generate in front of NEW button(next/prev...java script text box  hi, I created a button when i click
enable text box and label on selection
enable text box and label on selection  hello, Please tell me how to enable label and text box on selection of drop down list box. in drop down list box all values come from database. please reply
Text box control--keypress event
Text box control--keypress event  In my form have a text box...My requirement is... when is type characters in that box... before typing the 3rd character the space should come automatically or programmatically...the sturucture
enable text box
enable text box  Dear all I would like to enable a textbox by clicking on a button. pleas ehelp me out how can i do this regards JV
Drag a Text Box into dynamic positions
Drag a Text Box into dynamic positions  Plz can anyone tell how can i drag a text box using mouse or arrow keys... Im doing a accounts projects and i need this feature for cheque configuration
ModuleNotFoundError: No module named 'auto-resizing-text-edit'
ModuleNotFoundError: No module named 'auto-resizing-text-edit'  Hi...: No module named 'auto-resizing-text-edit' How to remove the ModuleNotFoundError: No module named 'auto-resizing-text-edit' error? Thanks   
ModuleNotFoundError: No module named 'auto-resizing-text-edit'
ModuleNotFoundError: No module named 'auto-resizing-text-edit'  Hi...: No module named 'auto-resizing-text-edit' How to remove the ModuleNotFoundError: No module named 'auto-resizing-text-edit' error? Thanks   
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 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
To display suggestions in a text box - Ajax
the Ajax : Some steps to be memeber : 1)Create a text box on the JSP Page..., to get the suggestions i mean when i enter the alphabet in a text box(For ex:'A'), the names that starts from 'A' have to display in the text box
Version of com.tuyenmonkey>auto-fill-edit-text dependency
List of Version of com.tuyenmonkey>auto-fill-edit-text dependency
how to create a text box using awt
how to create a text box using awt  give an example how creat multi buttons & text boxes
How to assign a default value to text box in netbeans
How to assign a default value to text box in netbeans  I have a java application,and i want to assign a default variable to the textbox
create text box by clicking button and submittong text in text box using submit
create text box by clicking button and submittong text in text box using... is created. and i want to do that when i enter the text input in text box and when i... box in SOP). i also want the text box should generate in front of NEW button
J2ME Text Box Example
J2ME Text Box Example       This application illustrates how to create the text box using TextBox class. The TextBox class is a Screen that allows the user to enter and edit text
populating text box using jsp code
populating text box using jsp code  Sir, How to populate related values in a text box after selecting value from drop down list using JSP and mysql...].text; window.location.replace("http://localhost:8080/examples/jsp
Auto grow Text Area using jQuery plug-in
Auto grow Text Area using jQuery plug-in In this section, you will learn how to create a text area which auto grow on increment of the content using jQuery... increase until you reach to 7th line of the text box . When you reach
how to display webservice response in a text box
how to display webservice response in a text box  Hallo, i have created a webservice and when i sended request to my webservice its sending proper response . the point is how to dispaly the response values in a text box usinj
Change background color of text box - Java Beginners
Change background color of text box  Hi how can i change the background color to red of Javascript text box when ever user enters an incorrect value while on entering a correct value its background color should change green
On click Checkbox values displayed in text box
On click Checkbox values displayed in text box  Hi sir, If i onclick the checkbox values should be displayed in text box, the following code is working properly in Internet Explorer browser but its not working in Google chrome
On click Checkbox values displayed in text box
On click Checkbox values displayed in text box  Hi sir, If i onclick the checkbox values should be displayed in text box, the following code is working properly in Internet Explorer browser but its not working in Google chrome
Maven Dependency auto-fill-edit-text >> 1.0.0
You should include the dependency code given in this page to add Maven Dependency of com.tuyenmonkey >> auto-fill-edit-text version1.0.0 in your project
List the names of classes used to create button and text box in Java.
List the names of classes used to create button and text box in Java.  List the names of classes used to create button and text box in Java
Maven Repository/Dependency: com.tuyenmonkey | auto-fill-edit-text
Maven Repository/Dependency of Group ID com.tuyenmonkey and Artifact ID auto-fill-edit-text. Latest version of com.tuyenmonkey:auto-fill-edit-text dependencies. # Version Release Date You
how can i store text box values as it is in database table
how can i store text box values as it is in database table  CUSTOMER DESCRIPTION
Text box size varying in IE 7 but ok in firefox - Java Beginners
Text box size varying in IE 7 but ok in firefox  I have problem with the size of text field which varies in IE 7 only but its fixed in Firefox( I... box size and placed in td with same width ,STill the first text box grows
JDialog to create a customized dialog box for entering text data
JDialog to create a customized dialog box for entering text data   ... dialog box for entering text data. The dialog can be split into panes, left pane can contain an image file and the right pane will contain multiple text fields
retrieve value from db in text box + calendar implementation.
retrieve value from db in text box + calendar implementation.  I... there is already a text box..Now i want to get the value retrieved from database in that text field how can i do it... Please help...   Please visit
instead of text boxe i have to show check box as selected.
instead of text boxe i have to show check box as selected.  i have one text field. in that iam getting boolean value either true or false from the database. when ever the valsue is there in textfield, instead of text boxe i
To Retain the values entered in the text box after submit in jsp page
To Retain the values entered in the text box after submit in jsp page   i am working on a jsp pge which has many text boxes and one dynamic drop down. The functionality is when user enters comma separated values in those text
Fancy Box plug-in for text, portal & swf file
Fancy Box plug-in for text, portal & swf file In this section, you will learn how to display text, portal & swf file inside fancy box by clicking... click on any link like text, portal & swf file, the output will be open
form text box connection with mysql database feild - JDBC
form text box connection with mysql database feild  Respected Sir, What is the coding to connect a form text box field with mysql database table.../jsp/prepared-statement-query.shtml http://www.roseindia.net/jsp/submit-comments
How to get data from DB in to Text box by using Jsp & Ajax
How to get data from DB in to Text box by using Jsp & Ajax   I want to get the data from database in to text box in a jsp page by using Ajax. If I enter the letter A in the textbox it should show only those values which starts
retrieve the data to text fields from database on clicking the value of combo box
retrieve the data to text fields from database on clicking the value of combo box   retrieve the data to text fields from database on clicking the value of combo box . I am not getting it plz help me out .   hi
Display two alert box alternately by clicking on text
Display two alert box alternately by clicking on text In this tutorial , we will discuss about how to display two alert box alternately by clicking on text line. In this example, a text line is given ,when we click
Insert value of dynamic generated text box in jsp using javascript
Insert value of dynamic generated text box in jsp using javascript  hello sir , i want to generate dynamic text box at run time and i did that using... that dynamically generated text box value into database at a time without
How to show autocomplete textbox values on combo box option selection using database?
How to show autocomplete textbox values on combo box option selection using database?  When I select option(i.e First Year) then it will show list of student names in auto-complete text box
How to Validate dynamically created text box in HTML using Javascript
How to Validate dynamically created text box in HTML using Javascript  Here is the HTML code to create text boxes dynamically. It works properly.... And also how to validate the text boxes created dynamically. <html>
auto
auto  write a java code design an auto with as many feature as possible

Ads