JQuery
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
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;
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)getdata.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);
}
%>
Ads
Related Tutorials/Questions & Answers:
JQuery
JQuery how to use
jquery
Jquery
Jquery I am new to
Jquery. Can anyone please tell me how to use
jquery plugins in html
Advertisements
jquery
jquery What are the
Jquery similarities or difference with other java script libraries
JQuery
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
jQuery Hi,
What is
jQuery and how it is used to develop Web applications?
Thanks
jquery
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
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
JQuery
, use
jquery autocomplete
JQuery
using url of the doctors, use
jquery autocomplete
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
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 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 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
What is jQuery and how it is used?
What is
jQuery and how it is used? Hi,
I want to know more about the
jQuery as there is lot of demand of it in Job portals. In most of the website designing and development jobs
jQuery is a must.
What is
jQuery and how
What is jQuery and how it is used?
What is
jQuery and how it is used? Hi,
I want to know more about the
jQuery as there is lot of demand of it in Job portals. In most of the website designing and development jobs
jQuery is a must.
What is
jQuery and how
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
ModuleNotFoundError: No module named 'jquery'
ModuleNotFoundError: No module named '
jquery' Hi,
My Python... '
jquery'
How to remove the ModuleNotFoundError: No module named '
jquery'... to install padas library.
You can install
jquery python with following command
ModuleNotFoundError: No module named 'jquery'
ModuleNotFoundError: No module named '
jquery' Hi,
My Python... '
jquery'
How to remove the ModuleNotFoundError: No module named '
jquery'... to install padas library.
You can install
jquery python with following command
jQuery ajax get example
jQuery ajax get example Hi,
How I can use
jQuery for get request? Give me code for
jQuery ajax get request.
Thanks
jquery post data error
jquery post data error getting post data error in
JQuery ..any idea why?
Please visit the following link:
JQuery Post Data