This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "dropdown filter" Watch "dropdown filter" New topic
Author

dropdown filter

Anonymous
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!!


Dave
Jesse Beaumont
Ranch Hand

Joined: May 30, 2002
Posts: 43
Hi,
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 = "";
DriverManager.registerDriver
(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 (rs1.next()) {
String dbVal = rs1.getString(1);
String selected = "";
if(selbrhVal.equals(dbVal)) selected="selected";
%>
<option value="<%=dbVal%>" <%=selected%>>
<%=rs1.getString(1) %>
</option>
<% } %>
Hope that helps


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

Joined: Nov 22, 2008
Posts: 18944
Hi,
@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 ]
Anonymous
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: http://aspose.com/file-tools
 
subject: dropdown filter
 
Similar Threads
two dropdown menus
multiple processes... only want one
nested resultsets
The program error!
How do I get Calculation to Work