新网创想网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

怎么用JavaScript编写简单的抽奖程序

本篇内容介绍了“怎么用JavaScript编写简单的抽奖程序”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

创新互联建站-专业网站定制、快速模板网站建设、高性价比剑河网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式剑河网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖剑河地区。费用合理售后完善,十载实体公司更值得信赖。

1.需求说明

某公司年终抽奖,需要有如下功能

1)可以根据实际情况设置到场人数的***值

2) 点击“开始”,大屏幕滚动,点击“停止”,获奖者的编号出现在大屏幕上

3)在界面里显示全部奖项获奖人编号

4)不重复获奖

5)不会因为输入错误而导致抽奖结果异常。

2.代码呈上

         某公司周年庆抽奖             var timer;       var flag = new Array(100);       var existingnum = new Array(100);       var clickTimes = 0;       var randnum;       var cellnum =1;       var mobile;       var num ;       function check_input(){             var input = document.getElementById("real_num").value;           var re = /^[1-9]+[0-9]*]*$/;           if (!re.test(input)){                 alert("请输入正整数");                 window.location.href=window.location.href;                  return false;              }          }            //get the random numbers from the mobile array every 0.05s       function setTimer(){           timer = setInterval("getRandNum();",50);           document.getElementById("start").disabled = true;           document.getElementById("end").disabled = false;       }          function getRandNum(){           document.getElementById("result").value = mobile[GetRnd(0,num)];       }          function GetRnd(min,max){            randnum = parseInt(Math.random()*(max-min+1));           return randnum;       }          //------------------------------------------------          //turn the input's running down       function clearTimer(){           noDupNum();           clearInterval(timer);           document.getElementById("start").disabled = false;           document.getElementById("end").disabled = true;       }       // Re defined array:change the length of the array and delete the checked one       function noDupNum(){           mobile.removeEleAt(randnum);           var o = 0;           for(p=0; pthis.length){return false;}               this.splice(dx,1);           }                
                          
                   

获奖小伙伴

                   

                                          

                   

                                                                 

                   

一等奖(1名)

                                                                                                                                  

二等奖(2名)

                                                                                                                                                         
           
           

           

                          

系统设置

                                                                 活动人数                                                                                                                                                                                    
                              

           
       
      

3.丑陋截图

我很丑,但是我很温柔~

怎么用JavaScript编写简单的抽奖程序

“怎么用JavaScript编写简单的抽奖程序”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注创新互联网站,小编将为大家输出更多高质量的实用文章!


名称栏目:怎么用JavaScript编写简单的抽奖程序
网站链接:http://www.wjwzjz.com/article/johgid.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP