<select name="select">
<%
   String sql = "select id, name from members";
   int id = 0;
   String nanme = "";
   try{
       ResultSet rs = DB.executeQuery(sql)
       while(rs.next()){
            id = rs.getInt("id");
            name = rs.getString("name");
%>
 <option value=<%=id%>> <%=name%> </option>
<%
       }//while
   }catch(SQLException e){
        //handle Database connection
   }
%>

解决方案 »

  1.   

    TO: Tasia(非典型…………) 
    这个程序我试了不行,取不到id和name 的值也不是联动下拉式列表框
    就是select变化的同时在下面的文本框显示出内容
    其中的内容都是数据库中的
    也就是通过select被选择的项访问数据库一条记录中的其他字段
      

  2.   

    <form name=addForm>
    <select name="select1" onchang="xxx();">
    <%
       String sql = "select id, name from members";
       int id = 0;
       String nanme = "";
       try{
           ResultSet rs = DB.executeQuery(sql)
           while(rs.next()){
                id = rs.getInt("id");
                name = rs.getString("name");
    %>
     <option value=<%=id%>> <%=name%> </option>
    <%
           }//while
       }catch(SQLException e){
            //handle Database connection
       }
    %><input type=text name=in><script>
         function xxx(){
              document.addForm.in.value=document.addForm.select1.Options[document.addForm.select1.selectedIndex].text 
    }
    </script>
      

  3.   


     <option value=<%=id%>> <%=name%> </option>
    加到while(rs.next()){}
    循环中
      

  4.   

    http://www.cnsxml.com/blogview.asp?logID=316
      

  5.   

    <input type=text name=in>
    <input type=text name=in1>
    <input type=text name=in2><script>
         function xxx(){
    document.addForm.in.value=document.addForm.select1.Options[document.addForm.select1.selectedIndex].text ;document.addForm.in1.value=document.addForm.select1.Options[document.addForm.select1.selectedIndex].text ;document.addForm.in2.value=document.addForm.select1.Options[document.addForm.select1.selectedIndex].text ;
    }
    </script>
      

  6.   

    我封了:<select name=id>
     <%=type%>
    </select>其中: type=SelectList("select pk,youwant from table");
    pk:主健
    youwant: 你想把他的植 放到 <select>中的列名 
    table: 表名你把 下面的方法放到 javabean 或 你自己的 class ,再把Connection con=DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:ORCL","siyo","1111"); 改成你的oracle 就行了SelectList(String sql): 为: static public String SelectList(String sql)
     {
      String sel="";
      try{
      Class.forName("oracle.jdbc.driver.OracleDriver");
      ResultSet result=null;
      Connection con=DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:ORCL","siyo","1111");
      Statement state=con.createStatement();
      result=state.executeQuery(sql);
      while(result.next())
      {
      sel+="<option  value="+result.getString(1)+">"+result.getString(2)+"</option>";
      }
      }
      catch(Exception e_1)
    {
      System.out.println(e_1);
    }
      return sel;
     }