I have a setup with two listboxes on my JSP page. The first listbox is initially populated with data from the database. When a user selects an item in the first listbox, I want the second listbox to be filled with corresponding database data using Ajax. Since I am new to JSP, I am seeking assistance.
Below is the JavaScript code I have been using to fetch the selected value from the first listbox.
<script type="text/javascript" >
$(document).ready(function(){
$("#rt_select").click(function() {
var option = $('#lstsprintid').val();
alert(option);
return option;
});
});
</script>
My problem lies in integrating the JavaScript returned value into my JSP page. Presented below is the multiple select listbox where the data is sourced from the database.
<p>Select Name :
<select size="3" id="lstsprintid" multiple="multiple">
<%
while(rs.next())
{
String name = rs.getString("s_name");
%>
<option value="<%=name %>"><%=name %></option>
<%
}
%>
</select>
I need guidance on which JavaScript code to implement in order to retrieve the list of values selected in the above listbox.
<%
String s1 = request.getParameter("txt_test");
out.println(s1);
Statement st1= con.createStatement();
ResultSet rs1=st1.executeQuery("Select sprint_id from sprint where sprint_name in ("+ s1 +")");
%>