<%@ page language="java" import="java.sql.*,java.util.*" pageEncoding="gb2312"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
//1.加载驱动 
Class.forName("oracle.jdbc.driver.OracleDriver"); 
//2.找开连接 
String OracleURL = "jdbc:oracle:thin:@192.168.4.202:1521:ujpcn";
Connection conn=DriverManager.getConnection(OracleURL,"netcool","netcool"); 
//xxxx这里是数据库的用户名,****这里是数据库的密码。 
//3.创建statement 
Statement stat=conn.createStatement(); %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'MyJsp.jsp' starting page</title>
    
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->  </head>
  
<body>  <div align="center">&quot;自由短信发送页面</div>
  <form id="form1" name="form1" method="post" action="">
    <label>
     <div align="center">短信内容编写栏:
       (每条短信可含60个字符,超出将被拆分)
       <input type="submit" name="Submit7" value="发送短信" />
       <input type="submit" name="Submit" value="退出" />
     </div>
    </label>
    <label></label>
    <label>
    <div align="center">
      <textarea name="textarea3" cols="60" rows="8"></textarea>
      <br />
      <div align="center"><br />
      </div>
    </div>
    </label>
  </form>
  <div align="center">
    <table width="545" height="22" border="0">
      <tr>
        <td width="225"><div align="center">可选收件人列表</div></td>
        <td width="77">&nbsp;</td>
        <td width="229"><div align="center">已选收件人列表</div></td>
      </tr>
    </table>
    <table width="410" border="0" height="330">
              
      <tr>
        <td valign="top"><br></td><td width="227" rowspan="6">
        <select   id="s1" onpropertychange="javascript:checkButtonStatus();"     multiple   style="WIDTH:   147px;   HEIGHT:   200px">
 <%
//4.执行SQL 
ResultSet rs=stat.executeQuery("select ChooseAddressee from ChooseAddressee");
//最后再把rs里面的值循环取出来 
                  while(rs.next()){ 
              //rs.getInt(); 
                }
                rs.close();
   %>
  <option   value=""></option>
  <option   value=""></option>
  <OPTION   value=""></OPTION>
  <OPTION   value=""></OPTION>
  <OPTION   value=""></OPTION>
 </select> 
        </td>
        <td width="74">&nbsp;</td>
        <td width="227" rowspan="6">
        <select   id="s2"     multiple   style="WIDTH:   147px;   HEIGHT:   200px"   onpropertychange="javascript:checkButtonStatus();"   >   
  </select> 
                </td>
      </tr>
      
      <tr>
        <td valign="top"><br></td><td><form id="form5" name="form5" method="post" action="">
          <label></label>
          <div align="center">
 <INPUT   class="btn2"   id="btnAllLeft"   onclick="transferItem(-2);"   type="button"   value="&lt; &lt;" name="btnAllLeft2">
          </div>
      </form>    </td>
    </tr>
      <tr>
        <td valign="top"><br></td><td><div align="center">
          <form id="form6" name="form6" method="post" action="">
            <label>
 <INPUT   class="btn2"   id="btnAllRight"   onclick="transferItem(2);"   type="button"   value="&gt; &gt;" name="btnAllRight"> 
             </label>
          </form>
        </div></td>
    </tr>
      <tr>
        <td valign="top"><br></td><td><div align="center">
          <form id="form7" name="form7" method="post" action="">
            <label>
 <INPUT   class="btn2"   id="btnLeft"   onclick="transferItem(-1);"   type="button"   value=" &lt; "  name="btnLeft2">
            </label>
          </form>
        </div></td>
    </tr>
      <tr>
        <td valign="top"><br></td><td><form id="form8" name="form8" method="post" action="">
          <label></label>
          <div align="center">
           <INPUT   class="btn2"   id="btnRight"   onclick="transferItem(1);"   type="button"   value=" &gt; "  name="btnRight2">
       </div>
      </form>    </td>
    </tr>
      <tr>
        <td valign="top"><br></td><td>&nbsp;</td>
    </tr>
    </table>
  </div>
<form action="" method="post" enctype="multipart/form-data" name="form9" id="form9">
<lable>
  <div align="center">导入收信人联系方式
    <input name="file" type="file" size="40" />  
    <input type="submit" name="Submit6" value="导入" />
  </div>
</lable>
</form>
</body>
</html>
<SCRIPT   LANGUAGE=javascript> 
<!-- 
function  transferItem(iDirect)  
 { 
   var   oListLeft   =   document.all.s1; 
   var   oListRight   =  document.all.s2; 
   if(iDirect<0) {   
   oListLeft   =document.all.s2;   
   oListRight  =document.all.s1; 
   } 
   iDirect   =   iDirect>0?iDirect:-1*iDirect; 
   for   (var   i=0;i<oListLeft.options.length;i++) 
   { if   ((iDirect   ==1   &&   oListLeft.options[i].selected   )||   iDirect   ==2   ) 
   { var   oldOp   =   oListLeft.options[i]; 
   var   newOp   =   
   new   Option(oldOp.text,oldOp.value); 
   oListRight.options.add(newOp); oListLeft.options[i]   =   null; i--; } } 
   checkButtonStatus(); 
   }
        
 function   checkButtonStatus()   
   { var   oListLeft   =   document.all.s1; 
   var   oListRight   =   document.all.s2; 
   var   btn1   =   document.all.btnLeft; 
   var   btn2   =   document.all.btnRight; 
   var   btn3   =   document.all.btnAllLeft; 
   var   btn4   =   document.all.btnAllRight; 
   // alert(bHaveCheckedOne(oListLeft)); 
   btn1.disabled   =!bHaveCheckedOne(oListRight); 
   btn2.disabled   =!bHaveCheckedOne(oListLeft); 
   btn3.disabled   =oListRight.options.length<=0; 
   btn4.disabled   =oListLeft.options.length<=0;   }     
 function   bHaveCheckedOne(obj)   
   { for(var   i=0;i<obj.options.length;i++) 
   {     if(obj.options[i].selected)     
   {               return   true;     } 
   } return   false;   
   }   //--> 
</SCRIPT>
是红字部分。。我应该如何把值赋进LIST里?

解决方案 »

  1.   

    <% 
    //4.执行SQL 
    ResultSet rs=stat.executeQuery("select ChooseAddressee from ChooseAddressee"); //最后再把rs里面的值循环取出来 while(rs.next()){ %>
    <option value="<%=rs.getXXX()%>"...</option>
    <%
     } rs.close(); 
    %>
      

  2.   

    <option value="">我想问的是我怎么赋到这个里面?
      

  3.   

            <select   id="s1" onpropertychange="javascript:checkButtonStatus();"     multiple   style="WIDTH:   147px;   HEIGHT:   200px">
     <%
    //4.执行SQL 
    ResultSet rs=stat.executeQuery("select ChooseAddressee from ChooseAddressee");
    //最后再把rs里面的值循环取出来 
                      while(rs.next())
                    { 
    System.out.println("" + rs.getInt(1) + ""); 
    %>
    <option   value=<%=rs.getInt(1) %>></option> 
       <%             }
                    rs.close();
       %>
    <option   value=""></option>
      <option   value=""></option>
      <OPTION   value=""></OPTION>
      <OPTION   value=""></OPTION>我这样写了但是还是没有取得数据画面上的LIST还是空白的
      

  4.   


    <select  id="s1" onpropertychange="javascript:checkButtonStatus();"    multiple  style="WIDTH:  147px;  HEIGHT:  200px"> 
    <% 
    //4.执行SQL 
    ResultSet rs=stat.executeQuery("select ChooseAddressee from ChooseAddressee"); 
    //最后再把rs里面的值循环取出来 
    while(rs.next()){ 
    %>
    <option value="<%=rs.getInt()%>"></option> 
    <%
    } rs.close(); %></select> 
    ≠ <select  id="s1" onpropertychange="javascript:checkButtonStatus();"    multiple  style="WIDTH:  147px;  HEIGHT:  200px"> 
    <% 
    //4.执行SQL 
    ResultSet rs=stat.executeQuery("select ChooseAddressee from ChooseAddressee"); 
    //最后再把rs里面的值循环取出来 
                      while(rs.next()) 
                    { 
    System.out.println("" + rs.getInt(1) + ""); 
    %> 
    <option  value= <%=rs.getInt(1) %>> </option> 
      <%            } 
                    rs.close(); 
      %> 
    <option  value=""> </option> 
    <option  value=""> </option> 
    <OPTION  value=""> </OPTION> 
    <OPTION  value=""> </OPTION> 自己好好去比较下这两人段代码的区别再看看页面生成的代码
      

  5.   


    <option  value=""> </option>
    这里没赋值啊 
    <option  value= <%=rs.getInt(1) %>>这里也要内容的 </option>
      

  6.   


    一条记录那么多字段,你想要哪个显示就用哪个阿 <%=rs.getXXX(X) %>
      

  7.   

    <option  value= '<%=rs.getInt(1) %>'>是不是需要加上'号啊