<html>
<select name="sel" onchange="check()"> 
<option value="aaa">aaa</option>
<option value="bbb">bbb</option>
</select> <script type="text/javascript">
  
  function check()
  {
var id = document.getElementsByName("sel").value;
window.location.href='b.jsp?ww='+id;</script></html>
这是我传送端的代码 就是想从选项中取值然后传给b.jsp 但就是不传
<html>
<%
String kk=request.getParameter("ww");
%><%out.print(kk);%>
</html>
这是b.jsp代码 求大神指出错误

解决方案 »

  1.   

    document.getElementsByName("sel")返回的是个数组改成:
    document.getElementsByName("sel")[0].value;
      

  2.   

    window.location.href='b.jsp?ww='+id;
     
    你这样得到的ww是空值吧?
    window.location.href='b.jsp?ww="+id+"';
    这样试试吧。
      

  3.   

    document.getElementsByName("sel")
    这是个数组, 数组没有value属性。
      

  4.   

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>无标题文档</title>
    <script type="text/javascript">
       
      function check()
      {
    var id = document.getElementById("sel").value;
    alert(id);
    window.location.href='d.html?ww='+id;
    }
    </script></head><body>
    <select name="sel" id="sel"  onchange="check()">  
    <option value="aaa">aaa</option>
    <option value="bbb">bbb</option>
    </select>  
    </body>
    </html>
    这样就OK 了, 你的取出的值是空的
      

  5.   

    getElementsByName获取的是数组,你要么加个索引[0],要么给下拉表加个id用getElementsById获取值
      

  6.   

    document.getElementsByName("sel") 数组。。
      

  7.   

    把<select name="sel" onchange="check()">  
    <option value="aaa">aaa</option>
    <option value="bbb">bbb</option>
    </select> 改成
    <select name="sel" onclick="check()">  
    <option value="aaa">aaa</option>
    <option value="bbb">bbb</option>
    </select>