zoukankan      html  css  js  c++  java
  • select选中事件

    <!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>
        <title>无标题页</title>
        <script type="text/javascript">
        function showMessage()
        {
            if(document.getElementById("selectID").options[document.getElementById("selectID").selectedIndex].value==1)
            {
                alert("你好,你选择了第 1 个");
                document.getElementById("divMessage").innerText=document.getElementById("selectID").options[document.getElementById("selectID").selectedIndex].value;
            }
            else if(document.getElementById("selectID").options[document.getElementById("selectID").selectedIndex].value==2)
            {
                alert("你好,你选择了第 2 个");
                document.getElementById("divMessage").innerText=document.getElementById("selectID").options[document.getElementById("selectID").selectedIndex].value;
            }
            else if(document.getElementById("selectID").options[document.getElementById("selectID").selectedIndex].value==3)
            {
                alert("你好,你选择了第 3 个");
                document.getElementById("divMessage").innerText=document.getElementById("selectID").options[document.getElementById("selectID").selectedIndex].value;
            }
            else if(document.getElementById("selectID").options[document.getElementById("selectID").selectedIndex].value==4)
            {
                alert("你好,你选择了第 4 个");
                document.getElementById("divMessage").innerText=document.getElementById("selectID").options[document.getElementById("selectID").selectedIndex].value;
            }
        }
        </script>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    </head>
    <body>
    <select id="selectID" onchange="return showMessage()">
        <option value="0">-----请选择----</option>
        <option value="1">1</option>
        <option value="2">2</option>
        <option value="3">3</option>
        <option value="4">4</option>
    </select>
        <div id="divMessage"></div>
    </body>
    </html>

    无标题页

     
  • 相关阅读:
    使用PHPMYADMIN添加新用户和数据库
    phpMyadmin用户权限中英对照
    Asp生成xml乱码解放方法
    SQL Server 错误日志
    安装VS2005 SP1时失败(错误 1718。文件被数字签名策略拒绝)的解决办法!
    CKEditor 3 JavaScript API Documentation
    CKEditor在.NET中的应用
    IIS 添加网站显示错误消息 “无更多可用的内存以更新安全信息” 解决方法
    jQuery 操作Cookie
    JavaScript/HTML格式化
  • 原文地址:https://www.cnblogs.com/subtract/p/3787931.html
Copyright © 2011-2022 走看看