<select name="<%= selectname %>" onChange="<%= onchange %>">
<option value="<%=part_id%>" selected><%=part_name%> // 写个循环,内容从数据库中取.
</option>

解决方案 »

  1.   

    给你一个程序,我自己编的,可以将数据库中的某一列的数据写在下拉框里。
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    </head><body>
    <%
    String url=new String();
    String user= new String();
    String password = new String();
    url="jdbc:odbc:test";
    user="sa";
    password="****"; //该出为密码
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con= DriverManager.getConnection(url,user,password);
    Statement stmt = con.createStatement();
    String SQL = new String();
    SQL = "SELECT * FROM tablename";
    ResultSet rs = stmt.executeQuery(SQL);
    String nm= new String();
    %>
    <select name="aaa">
    <%
      while (rs.next()) {
        nm= rs.getString("某一列的字段名");
    %>  
      <option value="<%=nm%>">
    <%
      out.println(nm);
    }
    rs.close();
    stmt.close();
    con.close();
    %>
    </select></body></html>
      

  2.   

    你这样写死String 字段了!你应该包装好![email protected]