Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Generate random number

Avatar

Avatar
Validate 1
Level 7
kc
Level 7

Likes

0 likes

Total Posts

402 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 7
kc
Level 7

Likes

0 likes

Total Posts

402 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
kc
Level 7

21-10-2008

Hi all,



Does anyone know how I can generate a random number?



My idea is that I can create a loop for handling the indexes of a string one by one, but I don't know if it is possible to get a single random number.



Of course I could create my own custom service as well, but I would like to use the stand alone services first and fore most if it is possible.



Is it possible without a custom service?



Thanks in advance



Sincerely

Kim

Replies

Avatar

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

612 likes

Total Posts

7,689 posts

Correct Reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile

Avatar
Boost 500
Level 10
pguerett
Level 10

Likes

612 likes

Total Posts

7,689 posts

Correct Reply

692 solutions
Top badges earned
Boost 500
Boost 50
Boost 5
Boost 3
Boost 250
View profile
pguerett
Level 10

21-10-2008

There are functions in Javascript for this. Did a search on the web and come up with this one:



var num=Math.floor(Math.random()*1000)



Where num will contain a random number between 0 and 1000. If you want a different range change the 1000 to your max range.

Avatar

Avatar
Validate 1
Level 7
kc
Level 7

Likes

0 likes

Total Posts

402 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile

Avatar
Validate 1
Level 7
kc
Level 7

Likes

0 likes

Total Posts

402 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
View profile
kc
Level 7

21-10-2008

Thanks a lot Paul, that is very usefull, allthough I would have liked it to be possible without using the script-service.



Thanks again, I really appreciate it



Sincerely

Kim