Ajax

Ajax

View Answers

December 19, 2008 at 4:46 AM

Hi friend,

Code to help in solving the problem :

"combo.jsp"

<%@ page import="java.sql.*" %>
<html>
<head>
<style>
A:hover {text-decoration: none;

border: 0px;
font-size:14pt;
color: #2d2b2b; }
</style>

<link rel="stylesheet" type="text/css" href="datepicker.css"/>


<script type="text/javascript">
function showEmp(emp_value)
{
if(document.getElementById("emp_id").value!="-1")
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url="getuser.jsp"
url=url+"?emp_id="+emp_value

xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)

}
else
{
alert("Please Select Employee Id");
}
}

function stateChanged()
{
document.getElementById("ename").value ="";
document.getElementById("emp_id").value ="";
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{

var showdata = xmlHttp.responseText;
var strar = showdata.split(":");

if(strar.length==1)
{
document.getElementById("emp_id").focus();
alert("Please Select Employee Id");
document.getElementById("ename").value =" ";
document.getElementById("emp_id").value =" ";

}
else if(strar.length>1)
{
var strname = strar[1];
document.getElementById("emp_id").value= strar[2];
document.getElementById("ename").value= strar[1];
}

}
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
//Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
</script>

</head>
<body>
<form name="employee">
<br><br>
<table border="0" width="400px" align="center" bgcolor="#CDFFFF">
<div id="mydiv"></div>
<tr><td><b>Select Employee Id</b></td><td>
<select name="semp_id" onchange="showEmp(this.value);">
<option value="-1">Select</option>
<%



Connection conn = null;
String url = "jdbc:mysql://localhost:3306/";;
String dbName = "user_register";
String driver = "com.mysql.jdbc.Driver";
String userName = "root";
String password = "root";

int sumcount=0;
Statement st;
try {
Class.forName(driver).newInstance();

conn = DriverManager.getConnection(url+dbName,userName,password);
String query = "select * from employee_details";

st = conn.createStatement();
ResultSet rs = st.executeQuery(query);
%>

<%
while(rs.next())
{
%>

<option value="<%=rs.getString(1)%>"><%=rs.getString(1)%></option>

<%
}
%>

<%

}
catch (Exception e) {
e.printStackTrace();
}

%>
</select>
</td></tr>
<tr><td ><b>Employee Id:</b></td><td>
<input type="text" name="emp_id" id="emp_id" value=""></td></tr>
<tr><td><b>Employee Name:</b></td><td>
<input type="text" name="emp_name" id="ename" value=""></td></tr>

</table>
</form>
<table border="0" width="100%" align="center">
<br>
<br>
</table>
</body>
</html>

December 19, 2008 at 4:56 AM

<%@ page import="java.sql.*" %>
<%
String emp_id = request.getParameter("emp_id").toString();
String data ="";

Connection conn = null;
String url = "jdbc:mysql://localhost:3306/";;
String dbName = "user_register";
String driver = "com.mysql.jdbc.Driver";
String userName = "root";
String password = "root";

int sumcount=0;
Statement st;
try {
Class.forName(driver).newInstance();

conn = DriverManager.getConnection(url+dbName,userName,password);
String query = "select * from employee_details where eid='"+emp_id+"'";

st = conn.createStatement();
ResultSet rs = st.executeQuery(query);
while(rs.next())
{
data = ":" + rs.getString(2) + " " + rs.getString(3) +":"+ emp_id;
}


out.println(data);
}
catch (Exception e) {
e.printStackTrace();
}
%>

Thanks









Related Tutorials/Questions & Answers:
ajax
ajax  please describe the ajax
Ajax
Ajax  How to learn AJAX
Advertisements
Ajax
Ajax  Hi, What is Ajax? What is the use of Ajax? Thanks   Hi, Ajax is set of technologies used to develop dynamic web applications. In Ajax following technologies is used: a) JavaScript b) XML c) HTTP d) CSS Learn
Ajax
Ajax  how to impliment ajax in registration table using jsp-servlet
Ajax
Ajax  send the example to fetch the data from the server by using ajax in java. for ex:-if there are states which is used to display in frontend we use ajax. send it to me
Ajax
Ajax  how to include ajax in jsp page?   Hi, Please read Ajax First Example - Print Date and Time example.ADS_TO_REPLACE_1 Instead of using PHP you can write your code in JSP. Thanks
ajax
ajax  how to connect ajax with mysql without using php,asp or any other scripting language. please answer soon
Ajax - Ajax
Ajax  What is Ajax ? How one can use ajax with Java
ajax
ajax  HI, In my application using ajax if i type a managername in the textbox it should display all the employees under the that manager... me reg this. thanks KK   Combobox box using Ajax in JSP   i
Ajax
ajax where instead of a link a radio button can fetch the data and can populate a table.If ajax can be used,it would be a greater advantage.After fetching data
ajax
ajax  How can we fetch data in ajax through servlet?   "mainpage.jsp" <html> <head> <title>Ajax Example</title>...;/head> <body> <h1 align="center"><font color="#000080">Ajax
ajax
ajax  How can we fetch data in ajax through servlet?   "mainpage.jsp" <html> <head> <title>Ajax Example</title>...;/head> <body> <h1 align="center"><font color="#000080">Ajax
ajax
ajax  How can we fetch data in ajax through servlet?   "mainpage.jsp" <html> <head> <title>Ajax Example</title>...;/head> <body> <h1 align="center"><font color="#000080">Ajax
ajax
ajax  How can we fetch data in ajax through servlet?   "mainpage.jsp" <html> <head> <title>Ajax Example</title>...;/head> <body> <h1 align="center"><font color="#000080">Ajax
Ajax
options. I want to do it using ajax. My table is CREATE TABLE HT<em>
AJAX
ajax. My table is CREATE TABLE HTNEWMETER ( ID NUMBER (10) NOT NULL, METERNO
ajax
ajax  I am facing following problem, I am using ajax to get the data continousely without refreshing. Here i have devided a web page into 3 parts(top,left and right) using table in jsp. On the left part i am displaying some
AJAX - Ajax
AJAX  what is Ajax?WHAT IS THE USAGE OF IT?WHERE WE HAVE TO USE IT? GIVE ME EXPLANATION WITH EXAMPLE?  Hi friend, Ajax : Asynchronous JavaScript and XML or Ajax for short is new web development technique used
AJAX - Ajax
AJAX  What is AJAX?how we will use it in java?what is the use of AJAX?give me example?   hi friend, Ajax plays a major role... characteristics have made it popular among the users to develop their site using Ajax
ajax - Ajax
ajax  Hi all, I want ajax validation in struts1.0 , I tried from many days but, i cound't find solution.. I am attaching my code here. struts... ("Your browser does not support Ajax HTTP"); return; } var s
ajax - Ajax
ajax  Dear Roseindia, I want small application using ajax validation in struts1 login. I tried from many days but, i coudn't get solution..Do some favour me..it's urgent. Thanqs for advance.   Hi
Ajax - Ajax
that : form1.html where all Ajax code is written : function showHint...){ alert ("Your browser does not support AJAX!"); return
AJAX - Ajax
("Your browser does not support AJAX!"); return; } var url="http://localhost
AJAX with
AJAX with       Ajax resources, in a digg style, allows the user to register and addd his/her own links Read full DescriptionADS_TO_REPLACE_1
What is ajax? - Ajax
What is ajax?  What is Ajax Programming? Can any one share the basic examples of it? thanks
Ajax Learner - Ajax
Ajax Learner  Hi, This is Ziaul,I am working as Java/j2ee Developer from last one year. i have to use Ajax for my current project.pls guide me how should i proceed to learn Ajax. Thanks and Regards Ziaul Hauqe Siddique 
Ajax validation - Ajax
Ajax validation  how to validate a form using Ajax and php  ... you. Please visit for more informaton: http://www.roseindia.net/ajax/ajaxlogin/ajax-registration-program.shtml Thanks. Amardeep
Ajax Learner - Ajax
Ajax Learner  Hi, This is Ziaul,I am working as Java/j2ee Developer from last one year. i have to use Ajax for my current project.pls guide me how should i proceed to learn Ajax. Thanks and Regards Ziaul Hauqe Siddique 
ajax basics - Ajax
ajax basics  i need ajax basics where can i find these........................ pls help me thanx in advance  Hi friend, Ajax : Asynchronous JavaScript and XML or Ajax for short is new web development technique
ajax with php - Ajax
ajax with php  how to do autocomplete search using ajax wit php in object oriented format?.. data should me retrive from database.. plz the way?.. give some sample codings
Ajax form element - Ajax
Ajax form element  I have problem in passing a value into form feild using ajax. I want to get the value is as a parameter. Can some one help me plz
ajax in java - Ajax
ajax in java  Dear deepak sir, My page contain several control... will come "Caseno exist" Sir I am using Ajax first-time.Please help me.   Hi friend, Ajax : Asynchronous JavaScript and XML or Ajax for short
Ajax type
Ajax type  hiii, Is Ajax a technology platform or is it an architectural style
2 - Ajax
Is Ajax Synchronous or Asynchronous?  Can ajax synchronous or asynchronous? Why
ajax synchronisation
ajax synchronisation  how to stop ajax execution for some specific time
Ajax tutorials
Ajax tutorials  Hi, Why I should learn Ajax? What is the use of Ajax and which is the best tutorial to learn Ajax? Thanks
Ajax example
Ajax example   Hi, Where can I find Ajax example program? Thanks   Hi, Get it at: Ajax Tutorials First Ajax Example Ajax Login Example Thanks
Ajax with jsp - Ajax
Ajax with jsp  multiple combo boxes with ajax in jsp?  Hi friend, I am sending you a link. I hope that, this link will help you. Please visit for more information. http://www.roseindia.net/jsp
ajax jsp - Ajax
ajax jsp  multiple combo with ajax using jsp?  Hi friend, I am sending you a link. This link will help you. Please visit for more information. http://www.roseindia.net/jsp/comboSelect.shtml Thanks
ajax for sturts - Ajax
ajax for sturts  Hi, I am trying to connect to the struts action class using ajax but I am getting error(not able to call actionclass),but when i use servlets I can call easily. how to solv it? plz help me... thanks
displaying in ajax - Ajax
displaying in ajax  hi.. I have an Ajax page ,request gone to server... for the answer  Hi friend, Ajax example to solve the problem : "mainpage.jsp" Ajax Example function postRequest
any alternaive for AJAX - Ajax
developing a web application for my final year project. very one knows AJAX which... any... given below to create application in ajax...!");--------------Ajax Tutorialhttp://www.roseindia.net/ajax/  Yes
What is Ajax?
What is Ajax?  Hi, What is Ajax and what is use of Ajax in web programming? Thanks   Hi, Ajax stands for AJAX stands for Asynchronous... JavaScript and other technologies such as CSS and XML. Read more at What is Ajax
Learn Ajax
Learn Ajax  Hi, Give good links to learn ajax. What is the correct url at roseindia.net to learn Ajax? Thanks   Hi, If you are beginner in Ajax start learning from the index of Ajax tutorial. Start learning Ajax
Ajax samples
Ajax samples  Hi, Tell me the urls of ajax samples. I am trying to find good Ajax samples for learning Ajax programming quickly. As I have to work on an Ajax project in next few days. Thanks   Hi, Please see Ajax
Ajax in IE 7 - Ajax
Ajax in IE 7  My AJAX function does not update on IE 7. What can I do to solve this problem?  hai friend give cross browser...) { } } } This is the code u have to write in the AJAX based examples for cross Browser
Ajax user interface - Ajax
Ajax user interface  hello could anyone help my requirement is to design the database interaction using AJAX my requirement is a table... these all has to be do using JSP,AJAX,JDBC what exactly i needed
AJAX- Database not connected - Ajax
AJAX- Database not connected  Respected Sir/Madam, I am Ragavendran.R.. I am working with AJAX and Database.. Ajax code works fine but the database values are not retrieved if queried.. Instead, I could receive
code problem:ajax - Ajax
code problem:ajax  Hi,I am using ajax to populate a select box.for this I am writing out.write("ONE"); like that.it runs fine in firefox.bt not in IE.Can anyone help me out this... thanks
Table refresh with ajax - Ajax
Table refresh with ajax  I am using jsp/html in my code. Is it compulsory that i have to use a servlet to implement table refresh using ajax? Or jsp also would work? Rajatha

Ads