0
これは次のとおりです。私のJSPページでは、パラメータとして2つのラジオで選択された国のid
が必要なストアドプロシージャを使用してデータベースからドロップダウンを埋めたいあなたがアメリカを選択した場合、その国の国は満たされ、ニカラグアを選択した場合はその逆です)。私の質問によると、それはサーブレットを使用していない、問題は私がラジオのvalue
を選択することができないということです(変数 "国"の代わりに番号を渡すと、コンボが満たされます)。サーブレットなしのドロップダウンJSPデータベースストアドプロシージャ
これは私のコードです:
<label for="state">State</label>
<select name="ddStates" id="ddStates">
<option value="-1">Select State...</option>
<%
try {
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/nextnetcustomers", "root", "root");
int country = Integer.parseInt(request.getParameter("cntry"));
StringBuilder sb = new StringBuilder();
ResultSet rs = null;
PreparedStatement ps = null;
sb.append("{call SP_CATSTATES_LIST(?)}");
ps = conn.prepareCall(sb.toString());
ps.setInt(1, country);
rs = ps.executeQuery();
while (rs.next()) {
%>
<option value="<%=rs.getInt("IDCATSTATES")%>"><%=rs.getString("DESCRIPTION")%></option>
<%
}
} catch (Exception ex) {
ex.printStackTrace();
out.println("Error " + ex.getMessage());
}
%>
</select>
これはラジオです: の NICARAGUA –
Chris