Hi!
I'm having problems with a multiple select box in an edit page.
It is a box with categories, and the user may have selected several of the categories when he first registered.
In the edit page, I have problems showing which he already have selected.
My SQL statements:
ResultSet rs3 = stmt3.executeQuery("SELECT * FROM MyCalendarCategories WHERE userid=" + user);
ResultSet rs2 = stmt2.executeQuery("SELECT * from Category ORDER BY catid");
This is how I try to show the selected categories from the MyCalendarCategories table:
<select name="categories" size="8" multiple>
<%
String disp = "";
int val = 0;
boolean cat_test = false;
int catid = 0;
while(rs2.next()){
disp = rs2.getString("category");
val = rs2.getInt("catid");
while(rs3.next()){
catid = rs3.getInt("catid");
if(val == catid){
cat_test = true;
}
}
%>
<%if(cat_test == true){ %>
<option value="<%=val%>" selected> <%=disp%></option>
<%}else{ %>
<option value="<%=val%>"> <%=disp%></option>
<%
}
cat_test = false;
}
Any help appreciated!
regards,
Vidar