#1
  1. No Profile Picture
    matthewdoucette.com
    Devshed Novice (500 - 999 posts)

    Join Date
    May 2002
    Posts
    635
    Rep Power
    13

    Is there a Javascript Random Seed Function?


    I want to do some randomness, but I would like to do the same randomness everytime according to the day or the hour, etc...

    Is there a Javascript Random Seed Function that I can set to do this? I have looked and could not find anything.
    Matthew Doucette / Xona.com
  2. #2
  3. No Profile Picture
    Senior Citizen
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2001
    Location
    leftcoast
    Posts
    2,019
    Rep Power
    16
  4. #3
  5. No Profile Picture
    matthewdoucette.com
    Devshed Novice (500 - 999 posts)

    Join Date
    May 2002
    Posts
    635
    Rep Power
    13
    So I have to create my own random function? There is none in Javascript?
    Matthew Doucette / Xona.com
  6. #4
  7. No Profile Picture
    Senior Citizen
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jan 2001
    Location
    leftcoast
    Posts
    2,019
    Rep Power
    16
  8. #5
  9. No Profile Picture
    matthewdoucette.com
    Devshed Novice (500 - 999 posts)

    Join Date
    May 2002
    Posts
    635
    Rep Power
    13
    Originally posted by adios
    Jeez....

    Math.random()

    http://www.devguru.com/Technologies/...kref/math.html
    random Method
    This method takes no arguments and returns a pseudo-random number between 0 and 1. The random number generator is seeded from the current time.

    Syntax: Math.random()
    You obviously did not understand my question. I want to be able to set the random seed myself.

    "So I have to create my own random function?" should have read, "So I have to create my own random function in order to solve this problem?"
    Last edited by Doucette; October 25th, 2002 at 03:03 PM.
    Matthew Doucette / Xona.com
  10. #6
  11. No Profile Picture
    matthewdoucette.com
    Devshed Novice (500 - 999 posts)

    Join Date
    May 2002
    Posts
    635
    Rep Power
    13
    Originally posted by adios
    http://developer.irt.org/script/598.htm
    I have already found that this function is not random enough for my needs.

    rand(50); produces 17

    with a seed of yyyymmdd (so 20021025 for October 25th, 2002)

    rand(50); produces 15 for the day before that, 13 for the day before that, 11... etc.
    Matthew Doucette / Xona.com

IMN logo majestic logo threadwatch logo seochat tools logo