I have a jsp page with the following:
<select name="classTitle" id="classTitle">
<option value="-1" name="title">Select class</option>
<%
try{
String qr="select * from class";
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/lab3","root","");
Statement stm=conn.createStatement();
ResultSet rs=stm.executeQuery(qr);
while(rs.next()){
%>
<option id="selectedClass" value="<%=rs.getString("classTitle")%>"><%=rs.getString("classTitle")%></option>
<%
}//end while
}//end try
catch(Exception ex){
ex.printStackTrace();
out.println("Error "+ex.getMessage());
}
%>
</select>
I want to add to the same form another field which will hold the corresponding class size (stored in table class) for the particular class selected. Then those values will be passed to the Servlet.
So far I have tried
<script>
$( '#classTitle' ).on( 'change', function( e ){
$("#results").html("You selected: " + selected);
});
</script>
and
<div id="results"></div>
for testing - does not work (may be because the original form is itself in a pop up window).