Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


debasis
AJAX
1 Answer(s)      4 years ago
Posted in : Design concepts & design patterns


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


Advertisement
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



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. 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
in a tabular form. Same for >33kv We can use ajax where instead of a link a radio button can fetch the data and can populate a table.If ajax can be used
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 Description
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 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
Advertisements
 

 

 

DMCA.com