在action里如何获取下拉框选中的中文值?急。。有的给个例子。

解决方案 »

  1.   

    String str = request.getParameter("下拉框的名字");
      

  2.   

    重点JavaScript是如何得到选中的值
      

  3.   

    用了action就不要用js获取了啊,要获取的话
    document.getElementById("下拉框ID").value
      

  4.   

     var _options = document.getElementById('oSelect2').options;
         for(var i = 0 ; i < _options.length;i++)
     {
    if(_options[i].selected)
    {
    alert(_options[i].value);
    alert(_options[i].text);
    }
     }
      

  5.   

    <SELECT name="condSel">
    <option value="-1">
    --查询条件--
    </option>
    <option value="0">
    价格
    </option>
    <OPTION value="1">
    名称
    </OPTION>
    </SELECT>Action中:
    int  cond=Integer.parseInt(request.getParameter("condSel"));是这样吗,好像不行,空指针异常。
      

  6.   

    把value的值和后面选项的值设一样的,document.getElementById("下拉框ID").value
      

  7.   

    function getIndexText(ID)
    {
      var oSelect = document.getElementById(ID);
      return oSelect.options[oSelect.selectedIndex].text;
    }