Hi can any one help me.
I am trying to select value for my first drop down from the data base[i.e dynamic drop down which will display all the country names]. Depending upon the value you have selected for the first drop down I would like to show all the related data in the second drop down[i.e. all the states for the selected country].
Here is the code:& lt%@page import="java.sql.*"%>
& lthtml>
& ltbody>
& lt%
String state = request.getParameter("state"); out.println(state);%>
& ltform name="my" action="abhay.jsp" method="post">
Country Name:& ltselect value=state onchange="my.submit();">
& lt%
if(state==null)
{
Connection con = null;
Statement st = null;
ResultSet rs = null;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:abhay","root","root");
st = con.createStatement();
String sa="select cname from cname";
rs = st.executeQuery(sa);
while(rs.next())
{
String y = rs.getString("cname");
%>
& ltoption value="& lt%= y%>">& lt%= y%>& ltoption>
& lt%
}
}
catch(Exception e)
{
out.println(e);
}
}
else
{
state= request.getParameter("state");
out.println(state);
}
%>
& lt/select>
& lt/form>
& ltform name="m">
& lt%
String h = request.getParameter("state") ;
out.println(h);
%>
& lt/form>
& lt/html>