hi,
i have two combo boxes one for country and another for state
both populated from data base dynamically.
<%@page import="java.sql.*"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
</head>
<body>
<select name="ctry">
<%
String city="";
Statement pstm;
ResultSet rs;
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection connect =DriverManager.getConnection("jdbc:oracle:thin:@172.17.0.14:1521:develop","devuser","devuser");
pstm = connect.createStatement();
rs = pstm.executeQuery("select * from sam1");
while (rs.next()) {
city = rs.getString(1);
%>
<option>
<%out.println(city); %> </option>
<%
}
rs.close();
pstm.close();
connect.close();
}
catch(Exception ex){
System.out.println(ex);
}
%>
</select>
<select>
<%
try{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection connect =DriverManager.getConnection("jdbc:oracle:thin:@172.17.0.14:1521:develop","devuser","devuser");
pstm = connect.createStatement();
rs = pstm.executeQuery("select * from sam1 where cntry = '"+ city +"'");
while (rs.next()) {
city = rs.getString(2);
%>
<option>
<%out.println(city); %> </option>
<%
}
rs.close();
pstm.close();
connect.close();
}
catch(Exception ex){
System.out.println(ex);
}
%>
</select>
</body>
</html>
the variable city is always point to the last value of the country
how to make this???
help me please
i search in google i saw onchange event, but i am not clear with so give some example code for that.