【发布时间】:2018-07-19 22:51:31
【问题描述】:
我想从数据库中获取项目名称到下拉框中。以下是将项目名称提取到下拉框中的代码。
<TD><SELECT name="ProjName" id="selectBox" style="fontfamily:Calibri;width:200px">
<%
try{
String ID = "";
String ProjName="";
Connection con = null;
response.setContentType("text/html");
con = DBConnection.createConnection();
//Class.forName("com.mysql.jdbc.Driver").newInstance();
//Connection connection = DriverManager.getConnection("jdbc:mysql://localhost/customers?user=root&password=root");
Statement statement = con.createStatement() ;
resultset =statement.executeQuery("SELECT ProjName,ID FROM myproject;") ;
%>
<% while(resultset.next()){ %>
<option><%= resultset.getString(1)%></option>
<% } %>
<%
//**Should I input the codes here?**
}
catch(Exception e)
{
out.println("wrong entry"+e);
}
%>
</select></td>
Now I want to display respective Project Id into textbox.For example when I select projectname1 from dropdown then automatically set projectId1 into textbox.
我不知道如何在选择下拉值时自动将相应的项目 ID 设置到文本框中。
【问题讨论】:
标签: javascript mysql jsp