Created
September 17, 2015 07:50
-
-
Save kidapu/7f6fd3e5a3d594a2ca51 to your computer and use it in GitHub Desktop.
抽選用スクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<title>アンケート抽選用</title> | |
<body> | |
<script type="text/javascript"> | |
var names = [ | |
"Aさん", | |
"Bさん", | |
"Cさん", | |
"Dさん", | |
"Eさん"]; | |
var max_num = 3; | |
Array.prototype.shuffle = function() | |
{ | |
var i = this.length; | |
while (i) | |
{ | |
var j = Math.floor(Math.random() * i); | |
var t = this[--i]; | |
this[i] = this[j]; | |
this[j] = t; | |
} | |
return this; | |
} | |
names.shuffle(); | |
for (var i=0; i<max_num; i++) | |
{ | |
var p = document.createElement('p'); | |
p.innerHTML = (i+1) + "位:" + names[i]; | |
document.body.appendChild(p); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment