Jsp and ajax
Hi
I am using jsp and ajax.I am retrieving the entire content from database(al.jsp) and
put it into a textbox.When i am clicking a combo box,it updates the selected value in the database(jag.jsp).
But it only works for first textbox and combobox.I noticed that it requires different id for textbox and combobox.
But i am not able to assign unique id.
Here is my code. Plz anybody help me.Its urgent.
al.jsp
<%@ page import="java.sql.*" %>
<%@ page import="javax.swing.*" %>
<%! Connection c;
Statement s;
ResultSet rs;
String cid,roll;
int i=0;
int j=1;
%>
<% try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
c=DriverManager.getConnection("jdbc:odbc:comdsn1");
s=c.createStatement();
rs=s.executeQuery("select * from comt1");
}
catch(Exception e)
{} %>
<html>
<script>
function ajax(str){
var xmlHttp;
var i;
var config=document.getElementById('comboBoxMenu').value;
var config1=document.getElementById('t1').value;
var tids=document.getElementById('comboBoxMenu').getAttribute('id');
alert("coboid:"+tids);
try{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
catch(e){
try{
xmlHttp=new XMLHttpRequest();
}
catch(e){
alert("your browser cant support");
}
}
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4 && xmlhttp.status==200){
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
document.write(xmlHttp.responseText);
}
}
var url="jag.jsp";
url=url+"?q="+config+"&q1="+config1;
xmlHttp.open("POST",url,true);
xmlHttp.send(url);
}
</script>
<body>
<form method="post" name="jag">
<center><table>
<%
try
{
rs=s.executeQuery("select * from comt1");
while(rs.next())
{
roll=rs.getString("rollno");
i=i+1;
j=j+1;
%>
<tr><td><input type="text" value="<%=roll%>" name="t1" id="${i}" readonly></td><td>
<select name="comboBoxMenu" id="${j}" onchange="ajax(this.value);">
<option value="present">present</option>
<option value="absent">absent</option>
</select>
</td>
<td></tr>
<% }
}
catch(Exception e){}
%>
</table>
</center>
</form>
<div id="myDiv">
</div>
</body>
</html>
jag.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%@ page import="java.sql.*" %>
<%@ page import="javax.swing.*" %>
<% String s1=request.getParameter("q");
String s2=request.getParameter("q1");
%>
<%try{
Connection c;
Statement st;
ResultSet rs;
JOptionPane.showMessageDialog(null,"welcome");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
c=DriverManager.getConnection("jdbc:odbc:comdsn1");
st=c.createStatement();
rs=st.executeQuery("select * from comt1");
JOptionPane.showMessageDialog(null,"welcome updated"+s2+s1);
st.executeUpdate("update comt1 set [9-10]='"+s1+"' where rollno='"+s2+"'");
rs=st.executeQuery("select * from comt1");
JOptionPane.showMessageDialog(null,"updated");
}
catch(Exception ex){
out.println(ex);
}
%>
Thanks in advance.Anybody help me.its urgent plz.
View Answers
Ads
Related Tutorials/Questions & Answers:
jsp and ajax
jsp and ajax how to enable or disable textbox using radio buttons by using
jsp and
ajax
jsp & ajax
jsp & ajax how to enable or disable textbox using radio buttons by using
jsp and
ajax?
plz help me.... i m new in
jsp &
ajax
Advertisements
Jsp and ajax
Jsp and ajax Hi
I am using
jsp and ajax.I am retrieving...;
function
ajax(str){
var xmlHttp;
var i;
var config=document.getElementById...";
url=url+"?
q="+config+"&q1="+config1;
xmlHttp.open("POST",url,true
Jsp and ajax
Jsp and ajax Hi
I am using
jsp and ajax.I am retrieving...;
function
ajax(str){
var xmlHttp;
var i;
var config=document.getElementById...";
url=url+"?
q="+config+"&q1="+config1;
xmlHttp.open("POST",url,true
Jsp and ajax
Jsp and ajax Hi
I am using
jsp and ajax.I am retrieving...;
function
ajax(str){
var xmlHttp;
var i;
var config=document.getElementById...";
url=url+"?
q="+config+"&q1="+config1;
xmlHttp.open("POST",url,true
Jsp and ajax
Jsp and ajax Hi
I am using
jsp and ajax.I am retrieving...;
function
ajax(str){
var xmlHttp;
var i;
var config=document.getElementById...";
url=url+"?
q="+config+"&q1="+config1;
xmlHttp.open("POST",url,true
ajax in jsp
ajax in jsp i m not able to compare string with the responseText value, though the value in the responsetext is of string type.
my code:
login.jsp
<html>
<head>
<meta http-equiv
ajax in jsp
ajax in jsp i m not able to compare string with the responseText value, though the value in the responsetext is of string type.
login.jsp:
print("<html>
<head>
<meta http-equiv="Content-Type" content="text
How to use ajax in jsp?
How to use
ajax in
jsp? Hi,
How i can access the server-side data in
JSP using the
Ajax?
Thanks
Hi,
You can use the
Ajax code to access the server side data from
JSP page.
Check the tutorial Combo Box Using
Ajax
jsp+ajax validation
jsp+
ajax validation hi,
I have created the
jsp form (course... 60% in the drop down list .how to validate student from using
ajax and
jsp... have created student
jsp form where it should display register number
ajax code for jsp
ajax code for jsp How to write
ajax code to retrieve information on to particular part of webpage when we select option from drop down box
The AJAX JSP Tag Library
The
AJAX JSP Tag Library
The
AJAX JSP Tag Library is a set of
JSP tags that
simplify the use of Asynchronous JavaScript and XML (
AJAX) technology in
JavaServer Pages. This tag
Ajax validation - JSP-Servlet
Ajax validation How to fade out the images when an onblur function is called moving from a text box to another??
can anyone help out with with the code
Selection With Ajax and JSP
Selection With
Ajax and JSP I am working at a
jsp page using
ajax for country , state, city selection.
so if he select country it will populate... the city.
I am doing it through two
jsp pages only.
Country1.jsp :
<%@ page
Ajax using jsp
Ajax using jsp <%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import...);
}
%>
Is there Any error...........In first Page I use
ajax for displaying
ajax using jsp
ajax using jsp <%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.StringTokenizer" %>
<%@ page import="java.lang.*" %>
<
Ajax not working in jsp
Ajax not working in jsp I'm using Netbean,
Ajax validation in the following code is not working the code succesfully run for first UID validation...; frmMain.elements[i].valid;
}
}
return blnValid;
}
//if
Ajax
DropDown in ajax+jsp
DropDown in
ajax+jsp I have four dropdown if i select first dd then only corresponding values must be there in 2nd dd,same with 3 and 4 and onchangfe it would not refresh the whole page.
Hi Friend,
Try the following
JQuery-JSP AJAX example not working
JQuery-
JSP AJAX example not working Hi, I while back ran you... started with
AJAX)), I was able to get it working. Just recently, I have been working on some additional development code using
AJAX and I was getting some
Ajax
Ajax how to impliment
ajax in registration table using
jsp-servlet
Combo Box Using Ajax In JSP
Combo Box Using
Ajax In
JSP
In this section, we develop an application to
Select the Data from database using
Ajax in combo box. We created two file
Popup Window using Ajax In JSP
Popup Window using
Ajax In
JSP
 ... Window application
using
Ajax in
JSP. For this, we will create the following...;
jsp:forward page="InsertData.jsp" />
<%
}
else
ajax
me reg this.
thanks
KK
Combobox box using
Ajax in
JSP
i...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
ajax
ajax please describe the
ajax