I have two listboxes on my JSP page. By default the first listbox is filled with database data, When the user selects an item in the 1st listbox, the second will filled accordingly with database data using Ajax. I am new to JSP. I need your help.
I used the below JavaScript code to retrieve the selected value in first listbox.
<script type="text/javascript" >
$(document).ready(function(){
$("#rt_select").click(function() {
var option = $('#lstsprintid').val();
alert(option);
return option;
});
});
</script>
I am unable to use the value returned from JavaScript in my JSP page. Below is my multiple select listbox where data is coming from db.
<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>
Which JavaScript code shall I use to get 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 +")");
%>