File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes dropdown filter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "dropdown filter" Watch "dropdown filter" New topic

dropdown filter

Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
i want to use >3 dropdown menus as a filter in one frame submitting with onchange - two problems :
on the second dropdown-onchange doesn't work;
the first dropdown doesn't keep the selection;
my experience is fiew and exhausting - please help !!

[ October 31, 2002: Message edited by: Werner Hirschlinger ]
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
Code Seeker
Welcome to the Java Ranch, we hope you�ll enjoy visiting as a regular however,
your name is not in keeping with our naming policy here at the ranch. Please change your display name to an appropriate name as shown in the policy.
Thanks again and we hope to see you around the ranch!!

Jesse Beaumont
Ranch Hand

Joined: May 30, 2002
Posts: 43
The first problem (the second onChange doesn't work) might be to do with the fact that your javascript submits compartment but the form is called Compartment (I don't know if DOM is case sensitive).
The second problem is just that you have to add the "selected" attribute to the option that you wish to select e.g.
<select name="selbrh" onchange="subbrh()">
//get the previously selected value
String selbrhVal = request.getParameter("selbrh");
if(selbrhVal == null) selbrhVal = "";
(new oracle.jdbc.driver.OracleDriver());
Connection con = DriverManager.getConnection
("jdbc racle:thin:@alois:1521 emrep2",
"repos_manager", "admin"
Statement stmt1 = con.createStatement();
ResultSet rs1 = stmt1.executeQuery
("select distinct branch from branch");
<% while ( {
String dbVal = rs1.getString(1);
String selected = "";
if(selbrhVal.equals(dbVal)) selected="selected";
<option value="<%=dbVal%>" <%=selected%>>
<%=rs1.getString(1) %>
<% } %>
Hope that helps

---<br />Time flies like an arrow,<br />Fruit flies like a banana
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
@Cindy : still beating, but far from taking off !
@Jesse :
thanks a lot for your worthy tips � I changed �Compartment�, but it didn�t work either � obscure is, that (the single) onchange works properly with 2 forms (sending the first selection to the second form), but when I add a third form, onchange of second form can�t send the selection to form 3 or the request.getParameter(selcot) Method of form 3 doesn�t receive the selection of form 2 (see first post).
I tried to save the selection in a variable and send it to form 2 (or 3) with no effect (see below).
The hint to the �selected� attribute is good � still working on that� (maybe i can use selectedIndex)
- I would be very grateful if somebody has more ideas

[ October 31, 2002: Message edited by: Werner Hirschlinger ]
[ October 31, 2002: Message edited by: Werner Hirschlinger ]
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
it's me one more time (fishing in mud)
- concerning to Topic: JSP / "Do I need to use ! for declarations" :
is it necessary to dis-/able a Single Thread because of succsessing "request" methods in each form ?
excuse my poorness in mind
I agree. Here's the link:
subject: dropdown filter
It's not a secret anymore!