Hi,
I did it but i totally changed my code i'm not used xmlObj i used xmlHttp
my coding are shown below
function loadContent()
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Your browser does not support Ajax HTTP");
return;
}
var stateValue = document.getElementById("State").value;
var url="getCity.jsp";
url=url+"?State="+stateValue;
xmlhttp.onreadystatechange=getOutput;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function getOutput()
{
if (xmlhttp.readyState==4)
{
document.getElementById("City").innerHTML=xmlhttp.responseText;
//alert(document.getElementById("City"));
}
}
function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
{
return new XMLHttpRequest();
}
if (window.ActiveXObject)
{
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}
but now i'm facing another problem this javascript goes to my getCity.jsp
in that JSP i want to get C_ID and City Name but i want to display only the city name in the combo box2
now i'm getting both the C_ID and city name in the combo box 2
below my getCity.jsp are shown
<%@ page import="java.sql."%>
<%@ page import="java.io."%>
<%@ page import="java.lang."%>
<%@ page import="java.text."%>
<%@page contentType="text/html" pageEncoding="UTF-8" language="java"%>
<%
String stateId = null;
Connection con = null;
PreparedStatement stmt = null;
ResultSet rs = null;
try
{
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","distil","distil");
stateId = request.getParameter("State");
String query = "select C_ID,CITY from mt2 where S_ID='"+stateId+"'";
stmt = con.prepareStatement(query);
rs = stmt.executeQuery();
String City = null;
while(rs.next())
{
City = "" + rs.getString(1) + " " + rs.getString(2);
//City = ""+ rs.getString(1);
}
out.println(City);
}
catch (SQLException ex){
System.err.println(ex.getMessage());
}
catch (Exception e){
e.printStackTrace();
}
finally{
//rs.close();
//con.close();
stmt.close();
}
%>