Author: jegg
The end of the year is approaching, and many companies are busy holding annual meetings. There are usually some lottery activities at the meetings. The following program is a simple lottery system written in JavaScript to share with everyone.
This code borrows the code of some netizens on the Internet and adds some improvements such as non-repeated lottery draws. The general idea is as follows:
1. Save all the lottery data (here is the mobile number) into the 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 array random INDEX at extremely short time intervals and display it.
4. Use the removeEleAt (index) function to delete the randomly generated mobile phone number. And reorganize the remaining mobile phone numbers to generate as a new array for next use.
How to use:
Copy the following original code to the WordPad, and then turn the txt attribute into html. If garbled code appears, please change the web page encoding (view--encoding).
The original code is as follows:
[Ctrl+A Select all Note:Introducing external Js requires refreshing the page before execution]
The end of the year is approaching, and many companies are busy holding annual meetings. There are usually some lottery activities at the meetings. The following program is a simple lottery system written in JavaScript to share with everyone.
This code borrows the code of some netizens on the Internet and adds some improvements such as non-repeated lottery draws. The general idea is as follows:
1. Save all the lottery data (here is the mobile number) into the 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 array random INDEX at extremely short time intervals and display it.
4. Use the removeEleAt (index) function to delete the randomly generated mobile phone number. And reorganize the remaining mobile phone numbers to generate as a new array for next use.
How to use:
Copy the following original code to the WordPad, and then turn the txt attribute into html. If garbled code appears, please change the web page encoding (view--encoding).
The original code is as follows:
[Ctrl+A Select all Note:Introducing external Js requires refreshing the page before execution]