码迷,mamicode.com
首页 > 其他好文 > 详细

select选中事件

时间:2014-06-14 16:18:43      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:style   class   blog   code   java   http   

<!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>

 

无标题页

 

select选中事件,布布扣,bubuko.com

select选中事件

标签:style   class   blog   code   java   http   

原文地址:http://www.cnblogs.com/subtract/p/3787931.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!