Naveen Kumar
1 Answer(s)      7 years ago
Posted in : Ajax

my requirement is: as i have a list of doctors in my table in the DB. a textbox is there in the browser it should display all the doctors names matching with the character typed in the textbox while typing(onkeyup event), textbox is in one jsp file, the ajax mathod call should be in another jsp file, use jquery autocomplete.

View Answers

February 8, 2011 at 6:03 PM

JSP Autocomplete with Ajax


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

var url="getdata.jsp";
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;
<form name="employee">
<input  type="text" name="name" id="name" onkeyup="showData(this.value);"><br>
<div id="mydiv"></div>



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

String name = request.getParameter("name").toString();
String buffer="<div>";  
           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+"%'");
catch (Exception e) {


Related Tutorials/Questions & Answers:
JQuery  how to use jquery
Jquery  I am new to Jquery. Can anyone please tell me how to use jquery plugins in html
jquery  What are the Jquery similarities or difference with other java script libraries
JQuery  How i begin JQuery and where i begin learning?   Please visit the following link: JQuery Tutorials Learn Jquery from the above link. Here you will get lot of examples with illustration
jQuery  Hi, What is jQuery and how it is used to develop Web applications? Thanks
jquery  how to display the leaves taken or holidays of the year or half working days in a calendar in some colors to identify the days using jquery plugin
JQuery  hi there, I am just beginner for jQuery and i want to know-what is jQuery ? How it is better than JavaScript ?   jQuery... JavaScript : Each jQuery returns itself so you can chain them together(Chaining
JQuery  how to create jquery auto-complete textbox ? in which data come from database table?   Please visit the following link: http://www.roseindia.net/tutorial/jquery/autoSuggestTextbox.html   thank you
, use jquery autocomplete
using url of the doctors, use jquery autocomplete
JQuery-Disabling element in JQuery.
JQuery-Disabling element in JQuery.   How can we enable/disable an element in JQuery
use of jquery
use of jquery  what is a jquery? what is the evalution of jquery?   Hello Friend, Please visit the following link: JQuery Tutorials Thanks
Use of jQuery
Use of jQuery  What is the use of jQuery?   Hi, jQuery is JavaScript Ajax library. Developer is using it to create rich internet applications. Read at jQuery Tutorial. Thanks
learn jquery
learn jquery   is it possible to learn myself jquery,ajax and json   Yes, you can learn these technologies by yourself. Go through the following links: Ajax Tutorials JSON Tutorials JQuery Tutorials
learn jquery
learn jquery   is it possible to learn myself jquery,ajax and json   Yes, you can learn these technologies by yourself. Go through the following links: Ajax Tutorials JSON Tutorials JQuery Tutorials
jQuery - jQuery Tutorials and examples
jQuery - jQuery Tutorials and examples       The largest collection of jQuery examples and jQuery Tutorials on the web. Learn and master jQuery from scratch. jQuery is nice
PHP and JQuery
PHP and JQuery  How to make validation using PHP and JQuery
jQuery Tutorials, jQuery Tutorial
jQuery Tutorials, jQuery Tutorial The jQuery tutorials listed here will help you in learning jQuery easily. We have given many articles and easy to understand examples to making learning path easier. These jQuery tutorials
dynamic jquery statement
dynamic jquery statement  dynamic jquery statement
PHP and JQuery
PHP and JQuery  How i validate input fields' data entry using JQuery
jQuery selectors
jQuery selectors       jQuery selectors In this tutorial we are discussing jQuery selectors. The jQuery selectors are one of the main feature in jQuery library
JQuery Spinner
JQuery Spinner   I am working in JQuery and i want to create SPinner for getting Credit Card Expiry Date in the form of MM/yyyy . Will you Please help me How to create the Spinner . Thank you. Regards Arun
Ajax in jQuery
Ajax in jQuery  How ajax can be use in JQuery?   Given below the code for ajax in jquery: $(document).ready(function() { $('#form').submit(function(){ var number = $('#number').val(); $.ajax({type:"post",url
jQuery Demos
jQuery Demos and quick examples       jQuery Demos The best way to learn a new technology... are providing the demo examples of jQuery that you can run in your browser
jquery session handling
jquery session handling  What is session handling in JQuery
parser jquery css
parser jquery css  How to parser jquery in css
jQuery Training
jQuery Training     jQuery Training for learn jQuery fast The jQuery training is designed to teach jQuery in 5 days. After taking our jQuery training you will be able to start
Conflict with jQuery scripts
Conflict with jQuery scripts  Hi, How to avoid Conflict with jQuery scripts while using jQuery with other libraries? Thanks   Hi, Read the using jQuery with other libraries tutorial for more information. Thanks
JQuery-What is Connect?
JQuery-What is Connect?   What is Connect in JQuery and how can i use
jQuery Features
jQuery Features       jQuery have lot of functionalities but some of the key features are given below : Selection of DOM elements : The jQuery selector provide us