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