Home >Web Front-end >JS Tutorial >Use Javascript to easily create a simple lottery system_javascript skills

Use Javascript to easily create a simple lottery system_javascript skills

WBOY
WBOYOriginal
2016-05-16 19:23:161361browse

Author: jegg
The end of the year is approaching, and many companies are busy holding annual meetings. There will usually be some lottery activities at the meeting. The following program is a simple lottery system written in javascript to share with everyone.
This code draws on the codes of some netizens on the Internet, and adds some improvements such as no repeated draws. The general idea is as follows:
1. Store all lottery data (here, mobile phone number) into an array.
2. Use the random function to randomly generate the INDEX of the array
3. Use the setInterval function to generate the mobile phone number corresponding to the random INDEX of the array at a very short time interval and display it.
4. Use the removeEleAt(index) function to delete randomly generated mobile phone numbers. And reorganize and generate the remaining mobile phone numbers into a new array for next use.
How to use:
Copy the following original code to the writing board, and then change the txt attribute to html. If garbled characters appear, please change the web page encoding (View - Encoding).
The original code is as follows:


[Ctrl A select all Note: If you need to introduce external Js, you need to refresh to execute ]
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Javascript MD4_BasicsNext article:Javascript MD4_Basics