Kern: Mathematikobjekt und Array -Objekt von JS
<! DocType html> <html Lang = "en"> <head> <meta charset = "utf-8"> <title> random </title> <style> #Awardlistdom {width: 100%;} </style> </head> <body> <Body> <Label für = "preislistdomie"> preisungsliste </label> <br> </head text "tection <Label für = "num"> Gewinne </Label> <br> <Eingabe type = "text" value = "" id = "num"> <br> <button id = "subieren"> starten Sie die Lotterie. -Random (): Gibt eine Zufallszahl zwischen 0 und 1 zurück. X: Startposition, y: Get und löschen die Nummer*/ function random (min, max) {return math.floor (min+math.random ()*(max-min)); } var awprialtlist = document.getElementById ("Awardlist"), num = document.getElementById ("num"), subled = document.getElementById ("subine"); var awardList=["first prize","second prize","second prize","third prize","third prize","third prize"," third prize","encouragement prize","encouragement prize","encouragement prize","encouragement prize","thank for participation","thank for participation","thank for participation","thank for participation","thank for participation","thank for participation","thank for participation"]; Awardlist.Value = Awardlist; subieren.onclick = function () {// Referenzarray var oldarray = preisliste; var rnum = random (0, OldArray.length); if (oldarray.length <1) {Awardlist.Value = "Event End"; Num.Value = "Event End"; } else {num.Value = OldArray [rnum]; OldArray.SPLICE (RNUM, 1); Awardlist.Value = OldArray; }} </script> </body> </html>Demo: http: //demo.vevb.com/js/2015/choujiang/
GitHub: https: //github.com/litengdesign/award