我有两个 html 下拉列表,它们的值是使用 jsp 从数据库中检索的。
<%
String query =" SELECT question_text,question_id FROM questions WHERE id = ?";
PreparedStatement stmt = conn.prepareStatement(query);
stmt.setString(1,request.getParameter("QID"));
ResultSet rs = stmt.executeQuery();
if(!rs.next()) {} else {%>
<form action="#" method="post">
<p> First Question </p>
<select name="currentQuestion">
<%do{%>
<option value="<%=rs.getString("question_id")%>"><%=rs.getString("question_text")%> </option>
<%}while(rs.next());}%>
</select>
<%
String query =" SELECT question_text,question_id FROM questions WHERE id = ? AND question id != ? ";
PreparedStatement stmt = conn.prepareStatement(query);
stmt.setString(1,request.getParameter("QID"));
stmt.setString(2,CHOOSEN QUESTION);
ResultSet rs = stmt.executeQuery();
if(!rs.next()) {} else {%>
<p> Next Question </p>
<select name="currentQuestion">
<%do{%>
<option value="<%=rs.getString("question_id")%>"><%=rs.getString("question_text")%></option>
<%}while(rs.next());}%>
</select>
</form>
现在,当用户从第一个下拉列表中选择特定问题时,第二个下拉列表的值不包括该问题怎么办?有人知道该怎么做吗?