取值不对 你传的是 select

解决方案 »

  1.   


        function openWindow(obj){
            window.open('2.jsp?name=' + document.getElementById('list').value ,'_blank');
        }另外option元素缺少value属性。
      

  2.   

    改成这样就成功了,如果用你的方法,需要在哪里添加怎么样的属性?
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Insert title here</title>
    <script type="text/javascript">    function openWindow(obj){
         var oSelect = document.all.list;
        
            window.open('2.jsp?name=' + oSelect.options[oSelect.selectedIndex].value ,'_blank');
        }
    </script></head>
    <body>
    <%
            Connection conn = null;
            PreparedStatement ps = null;
            ResultSet rs = null;
            ArrayList list = new ArrayList();
            conn = DBHelper.getMySql();
            String sql="select * from format_temp";
            try {
    ps = conn.prepareStatement(sql);
    rs = ps.executeQuery();
    while(rs.next()) {
    list.add(rs.getObject("name"));
    }

    } catch (SQLException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
        %> <form action="" method="post" name="form1" id="form1">
    <select name="listOption" id="list">
    <%for(int i=0;i<list.size();i++){%>
    <option><%=list.get(i).toString()%></option>
    <%}%> </select> 
    <input type="button" value="修改" onclick="openWindow(form1)">
    </form></body>
    </html>
    <body>
        <% String s = new String(request.getParameter("name").getBytes("ISO-8859-1"),"utf-8"); %>
        name:<%= s %> </body>