CISLA LOTERIE (2)

ID
Nazov / Name:
Popis / Description:
Dlzka / Length:
Testovane pod / Tested under:

 

033
p033.html / p033.zip
Po specifkovani pravidiel loterie, zobrazi nahodne vybraty pocet cisel
2341b
NN 4.04, IE 4.0

UKAZKA / CLICK HERE

Zdrojovy tvar / Source code:

<html> <head> <title> JavaScript DESTINATION - P033 </title> <script language="JavaScript"> <!-- function checkNumber(form){ if ((form.inputbox3.value != "3") && (form.inputbox3.value != "4") && (form.inputbox3.value != "5") && (form.inputbox3.value != "6")){ alert('Do polozky pocet cisel je mozne vlozit cislo v rozsahu 3-6') document.form.inputbox3.focus(); document.form.inputbox3.select(); } } function greaterThan(form){ if (form.inputbox2.value >= form.inputbox1.value) { alert('Vlozte vyssie cislo nez ste vlozili v polozke najnizsie cislo') document.form.inputbox1.focus(); document.form.inputbox1.select(); } } function getNumbers(form){ numb = new Array(6) var Different; for (var i = 0; i < form.inputbox3.value; i++) { Different = false; while (Different == false) { Different = true; high = Math.floor(form.inputbox1.value) - Math.floor(form.inputbox2.value); numb[i] = Math.floor(Math.random() * high) + Math.floor(form.inputbox2.value); for (j = 0; j < form.inputbox3.value; j++) { if ((numb[i] == numb[j]) && (i != j)) { Different = false; } } } } if (form.inputbox3.value == 6) { var numbers = numb[0] + " " + numb[1] + " " + numb[2] + " " + numb[3] + " " + numb[4] + " " + numb[5] } if (form.inputbox3.value == 5) { var numbers = numb[0] + " " + numb[1] + " " + numb[2] + " " + numb[3] + " " + numb[4] } if (form.inputbox3.value == 4) { var numbers = numb[0] + " " + numb[1] + " " + numb[2] + " " + numb[3] } if (form.inputbox3.value == 3) { var numbers = numb[0] + " " + numb[1] + " " + numb[2] } alert(numbers) } // --> </script> </head> <body> <FORM name=form> <table> <tr> <td> Pocet cisel: <td> <INPUT TYPE="text" NAME="inputbox3" size=1 maxsize=2 VALUE="" onBlur=checkNumber(this.form);> </td> </tr> <tr> <td> Najvyssie cislo: <td> <INPUT TYPE="text" NAME="inputbox1" size=2 maxsize=2 VALUE=""> </td> </tr> <tr> <td> Najnizsie cislo: <td> <INPUT TYPE="text" NAME="inputbox2" size=2 maxsize=2 VALUE="" onBlur=greaterThan(this.form);></td> </tr> <tr> <td colspan=2> <INPUT TYPE="button" NAME="button" Value="Vylosuj" onClick="getNumbers(this.form)"> </td> </tr> </table> </form> </center> </body> </html>
[ Navrat / BACK ]