zoukankan      html  css  js  c++  java
  • js如何控制select控件(下拉列表)

     把下面的代码保存为html文件在浏览器打开就可以看到效果了。

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>Select Test</title>
    </head>
    <script language="javascript">
    function $(o)
    {
        
    return document.getElementById(o);
    }
    </script>
    <body>
    <p>
      
    <select name="Region" id="Region">
        
    <option value="790">全部</option>
        
    <option value="791">济南</option>
        
    <option value="792">青岛</option>
      
    </select>
    </p>
    <p>
      
    <input type="button" name="Submit1" value="this.selectedIndex" onclick="alert($('Region').selectedIndex);" />
      
    <input type="button" name="Submit2" value="this.value" onclick="alert($('Region').value);" />
      
    <input type="button" name="Submit3" value="this.option[i].value" onclick="alert($('Region').options[$('Region').selectedIndex].value);" />
      
    <input type="button" name="Submit4" value="this.option[i].text" onclick="alert($('Region').options[$('Region').selectedIndex].text);" />
    </p>
    </body>
    </html>
  • 相关阅读:
    约瑟夫问题
    LCIS(最长公共上升子序列)
    Spfa求负环
    裴蜀(贝祖)定理
    Tarjan算法之简单缩点
    树形dp-二次扫描+换根
    sys.path.insert
    python学习之路(十二)
    python学习之路(十一)
    python学习之路(十)
  • 原文地址:https://www.cnblogs.com/Aricc/p/1189557.html
Copyright © 2011-2022 走看看