AJAX

Ads
 

AJAX

Thank you for all your help.This problem i asked you many days before,but did not get some answer.i will be obliged if you throw some light on this issue.

I have a table in which there are electrical meters with their details.This table NEW_METER stores all the details of meters.All meters are diveide into three categories.11KV,33KV and >33kv.all meters should have a testing date.I have a page in which there are 3 options with radio button with all options. e.g- 11kv* 33kv* >33kv*

*=radio button

After clicking on that button it should fetch all the meters details,whose testing dates were one year before from today.e.g-If am checking on 11th Jan 2011,it should whose(11kv) testing dates sre before 11th Jan 2010.(compare years).It should fetch all tha details of that meter and should populate a table with print options.

I want to do it using ajax.

My table is CREATE TABLE HTNEWMETER ( ID NUMBER (10) NOT NULL, METERNO VARCHAR2 (30) NOT NULL, PONO VARCHAR2 (30) NOT NULL, STORENAME VARCHAR2 (20), DELIVERYDATE DATE, MAPPING_STATUS CHAR (1) DEFAULT 'N', METERTESTINGDATE DATE, KVARATINGID NUMBER,

Sir,please help me.It is utmost urgent.pLEASE HELP ME.

Regards

View Answers

January 11, 2011 at 5:17 PM

Hi Friend,

Try the following code:

1)radiobuttons.jsp:

<%@page import="java.sql.*"%>
<html>
<head>
<script type="text/javascript">
function showData(value){ 
    alert("--------------"+value);
xmlHttp=GetXmlHttpObject()
var url="getInfo.jsp";
url=url+"?meter="+value;
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged() { 
if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ 
    document.getElementById("mydiv").innerHTML=xmlHttp.responseText;
    } 
}
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>
<input type="radio" value="11kv" id="radio" name="radio" onclick="showData(this.value);">11 KV<input type="radio" value="33kv" name="radio" id="radio" onclick="showData(this.value);">33 KV<input type="radio" value=">33kv" id="radio" name="radio" onclick="showData(this.value);">>33KV
<br><br>
<div id="mydiv"></div>

</body>
</html>

2)getInfo.jsp:

<%@page language="java" import ="java.sql.*, java.text.*,java.util.*" %>
<%
String fi=request.getParameter("meter");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c1 = Calendar.getInstance(); 
c1.set(2011, 0 , 11);
c1.add(Calendar.YEAR,-1);
String dd=sdf.format(c1.getTime());

String buffer="<table border='1'>";
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 htnewmeter where METERTESTINGDATE<'"+dd+"' ");
while(rs.next()){
buffer=buffer+"<tr><td>"+rs.getString(1)+"</td><td>"+rs.getString(2)+"</td><td>"+rs.getString(3)+"</td><td>"+rs.getString(4)+"</td></tr>";
}
buffer=buffer+"</table>";
response.getWriter().println(buffer);
%>

Thanks

Ads









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 connect ajax with mysql without using php,asp or any other scripting language. please answer soon
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  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 with
AJAX with       Ajax resources, in a digg style, allows the user to register and addd his/her own links Read full Description
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 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
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
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
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 sample
Ajax sample  Hi, Where I can find the samples of Ajax program? Thanks   Hi, Please see Ajax Tutorials. Thanks
Ajax wiki
Ajax wiki  Hi, What is the url of wiki for Ajax tutorial. Thanks   Hi, Here is the link: Wikipedia Ajax url. Thanks
Ajax scripts
Ajax scripts  Hi, Tell me the names of Ajax Scripts that can be used for writing Ajax based applications? Thanks   Hi, Please see the Ajax Web Framework page. Thanks
Ajax training
Ajax training  Hi, I am looking for Ajax Training. From where I get training on Ajax? Thanks   Hi, Please visit Ajax Training url. Thanks
ajax example
Ajax Example Here is the list of few Ajax examples at RoseIndia.net. Ajax example Ajax example   Hi, Where can I find Ajax example program? Thanks   Hi, Get it at: Ajax Tutorials First Ajax
Ajax applications
Ajax applications  Hi, Where can I find Ajax applications? Thanks
Ajax json
Ajax json  Hi, How consume json file in ajax program? Thanks
Ajax grid
Ajax grid  Hi, How I can create ajax grid in my program? Thanks
Ajax tools
Ajax tools  Hi, What all ajax tools are available for programming? Thanks

Ads