Hello All,
I am having difficulties while dealing with two linked drop down lists which the drop down list 1 will fetch the values from the DB and based on the user's selection, it will fetch the concerned records in drop down list 2.
I tried to do that in my jsp with that code, but it did not work and many people advised to use javascript. In fact, I don't know much more abot JS, so can you please help me
<select size="1" name="shop_category"><option value="NONE">
<%
try
{
ResultSet rs=null;
Statement st1=null;
String query = "select Category_name, category_id from shop_category_lkup";
st1 = conn1.createStatement();
rs = st1.executeQuery(query);
while(rs.next())
{
String sz_Selected="";
if (rs.getString("category_id").equals(shop_category))
{
sz_Selected = "selected";
}
%>
<option value="<%=rs.getString("category_id")%>" <%=sz_Selected%>>
<%=rs.getString("category_name")%></option>
<%
}
}
catch (Exception e) {
e.printStackTrace();
}
%>
</select>
<select size="1" name="rent_category"><option value="NONE">
<%
try
{
ResultSet rs=null;
Statement st1=null;
String query = "select r.Category_name, r.category_id from rent_category_lkup r, shop_categpry_lkup s where r.category_id=s.category_id";
st1 = conn1.createStatement();
rs = st1.executeQuery(query);
while(rs.next())
{
String sz_Selected="";
if (rs.getString("category_id").equals(rent_category))
{
sz_Selected = "selected";
}
%>
<option value="<%=rs.getString("category_id")%>" <%=sz_Selected%>>
<%=rs.getString("category_name")%></option>
<%
}
}
catch (Exception e) {
e.printStackTrace();
}
%>
</select>