以上省略
<script>
function 方法名()
{
var string=document.表单名.下拉列表名.value;
alter(string);
}
</script><body>
<select name="chose">
        <option>取值1</option>
        <option>取值2</option>
      </select>
本人菜鸟级别,求大侠帮忙
我想获取option 标签中的值 应该怎么办

解决方案 »

  1.   


    function 方法名() 

    var opts=document.表单名.下拉列表名.options; 
    alter(opts[0].text); 
    alter(opts[1].text); 
    }
      

  2.   

    Code:<html>
    <head>
    <title>wujinjian</title>
    <script type="text/javascript">
    function abc()
    {
    var selectobj=document.getElementById("xz");
    var idx=selectobj.selectedIndex;
    var textvalue=selectobj.options[idx].text; alert(textvalue);

    }
    </script>
    </head>
    <body>
    <form>
    <select id="xz">
    <option value="1111">1111</option>
    <option value="2222">2222</option>
    <option value="3333">3333</option>
    <option value="4444">4444</option>
    <option value="5555">5555</option>
    </select>

    <input type="button" value="确定" onclick="abc()">
    </form>
    </body>
    </html>
      

  3.   

    给select控件加一个id,例如:id="select1",然后:
    function getValue() 

    var index=document.getElementById("select1").selectedIndex; //获得索引 
    var val=document.getElementById("select1").options[index].text; alert(val); } 
      

  4.   

    获得选项option的值var obj=document.getElementById('mySelect');var index=obj.selectedIndex; //序号,取当前选中选项的序号var val = obj.options[index].value;获得选项option的文本var obj=document.getElementById('mySelect');var index=obj.selectedIndex; //序号,取当前选中选项的序号var val = obj.options[index].text;