![]() |
![]() |
![]() ![]()
Post
#1
|
|
Grupa: Zablokowani Postów: 206 Pomógł: 0 Dołączył: 9.03.2006 Ostrzeżenie: (0%) ![]() ![]() |
mam problem jak w js, wygenerowac, w petli, iles tam liczb od 1-20, ale zeby byly rozlozone losowo, i kazda z nich wystepowala dwa razy.
wiec bedziemy miec w sumie 40 liczb. |
|
|
![]() |
![]()
Post
#2
|
|
Grupa: Zablokowani Postów: 206 Pomógł: 0 Dołączył: 9.03.2006 Ostrzeżenie: (0%) ![]() ![]() |
albo zle cos robie, albo cos niedziala (IMG:http://forum.php.pl/style_emoticons/default/dry.gif)
Kod <html>
<head> <script language="JavaScript" type="text/javascript"> function rand(intStart, intEnd) { return intStart + Math.floor(Math.random() * (intEnd - intStart)); } function right6Generator(intStart, intEnd) { var arrNumbers = new Array(); var i = 0; while (intStart <= intEnd) { arrNumbers[i++] = intStart; arrNumbers[i++] = intStart++; } var arrResult = new Array(); for (i = arrNumbers.length - 1; i >= 0; i--) { intIndex = rand(0, i + 1); arrResult[i] = arrNumbers.splice(intIndex, 1); } return arrResult; } </script> </head> <body> <div onclick="right6Generator(1, 20)">aaaa</div> </body> </html> |
|
|
![]() ![]() |
![]() |
Aktualny czas: 7.10.2025 - 10:29 |