Dependent dynamic dropdown list from database jsp
Hi,I am trying dropdown list in jsp. first i am trying
bind dropdown list with district and then Taluka. When I select
district then automatically bind a taluka drop down list.
So how to do this, kindly make change in following. so
i can understand where is my mistake.
<%
Connection conn = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=GATEWAY", "sa", "allied007");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("Select ID, DISTRICT From District_Master");
Connection Talconn = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=GATEWAY", "sa", "allied007");
Statement Talstmt = Talconn.createStatement();
ResultSet Talrs = Talstmt.executeQuery("Select id, District_id, Taluka From Taluka_Master");
%>
<select id="ddlStateName" name="ddlStateName" class="columnwidth1">
<option value="0" selected>Select</option>
<% while (rs.next()) {%>
<option value="<%=rs.getString("ID")%>"><%=rs.getString("DISTRICT")%></option>
<% }%>
</select>
<select name="ddlTalukaName" class="columnwidth1">
<option value="0">Select</option>
<%
while (Talrs.next()) {%>
<option value="<%=Talrs.getString("ID")%>"><%=Talrs.getString("Taluka")%></option>
<%}%>
</select>