也就是如何用在JavaScript中引用select的文本?

解决方案 »

  1.   

    var oItems=document.all.select.options;
    var oItem=oItems[oItems.selectedIndex];
    alert(oItem.innerText);
      

  2.   

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>新建网页 3</title>
    </head>
    <body>
    <form>
    请选择一个水果:
    <select name="select" onchange="abc()">
    <option value="1">苹果</option>
    <option value="2">梨子</option>
    <option value="3" selected>香蕉</option>
    <option value="4">西瓜</option>
    <option value="5">葡萄</option>
    </select>
    <script language="javascript">
    function abc()
    {
    var oItems=document.all.select.options;
    var oItem=oItems[oItems.selectedIndex];
    alert(oItem.innerText);
    }
    </script>
    </form>
    </body>
    </html>
      

  3.   

    < select name="select" onChange="javascript:alert(this.options[selectedIndex].text);">
    < option value="1">苹果</option>
    < option value="2">梨子</option>
    < option value="3" selected>香蕉</option>
    < option value="4">西瓜</option>
    < option value="5">葡萄</option>
    < /select>谢谢啊,我也找到答案了~