htmlcssJavaScript网页开发:年会手机号抽奖案例

见过不少人、经过不少事、也吃过不少苦,感悟世事无常、人心多变,靠着回忆将往事串珠成链,聊聊感情、谈谈发展,我慢慢写、你一点一点看......

<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>抽奖</title>
        <style>
            #choujiang{
                display:block;
                width: 400px;
                margin: 0 auto;
                border:1px solid black;
                padding: 0;
                text-align: center;
                
            }
            #choujiang form .contents{
                display: block;
                width: 400px;
                height: 70px;
                background: #ff3435;
                color:black;
                font-weight: bold;
                text-align: center;
                line-height: 70px;
                cursor: pointer;
            }
            #choujiang form input{
                display:inline-block;
                width: 100px;
                height: 30px;
                border:0;
                border-radius: 15px;
                background: #34f4e4;
                line-height: 30px;
                color:red;
                font-family: 黑体;
                font-size:15px;
                font-weight: bold;
                margin-bottom: 15px;
                cursor: pointer;
            }
            #choujiang form label{
                display: block;
                width: 400px;
                margin: 0 auto;
                background: #ffffff;
                color:red;
                
            }

        </style>
    </head>
    <body>
        <!--
    抽奖,根据手机号码抽奖
    -->
        <div id="choujiang">
            <form action="">
                <div id="contents" class="contents" onclick="start_cj();">
                    <!--抽奖界面-->点击开始滚动手机号码
                </div>
                <br>
                <input id="cj" type="button" value="抽1次" onclick="choujiang(1);">
                <input id="cj" type="button" value="抽3次" onclick="choujiang(3);">
                <input id="cj" type="button" value="抽10次" onclick="choujiang(10);">
                <label id="show" class="show"></label>
            </form>
        </div>
        <script>
            //抽奖
            function choujiang(number) {
                var tel = "";
                for (var i = 0; i < number; i++) {
                    tel = tel + get_tel() + "  <br>  ";
                }
                //将抽奖结果放入到指定位置显示
                var show = document.getElementById("show");
                show.innerHTML = "<h1>恭喜以下手机用户获奖</h1>" + tel;
            }
            //启动抽奖
            function start_cj() {
                var tel = get_tel();
                document.getElementById("contents").innerHTML = tel;
                setTimeout("start_cj()", 10); //设置计时器,循环
            }
            //获取手机号码
            function get_tel() {
                var prefixArray = new Array("130", "131", "132", "133", "135", "137", "138", "170", "187", "189");
                var i = parseInt(Math.random() * 10);
                var prefix = prefixArray[i];
                for (var j = 0; j < 8; j++) {
                    prefix = prefix + parseInt(Math.random() * 10);
                }
                return prefix;
            }
        </script>
    </body>
</html>

关注我,不失联。有啥问题请留言。

感情恋爱合集https://blog.csdn.net/forever8341/category_12863789.html

职业发展故事https://blog.csdn.net/forever8341/category_12863790.html

常用代码片段https://blog.csdn.net/forever8341/category_12863793.html

程序开发教程https://blog.csdn.net/forever8341/category_12863792.html

自我备考经验 https://blog.csdn.net/forever8341/category_12863791.html

高阶高效代码https://blog.csdn.net/forever8341/category_12873345.html

金融语言解析https://blog.csdn.net/forever8341/category_12877262.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

我曾经是个程序员

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值