Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Random Numbers in javascript

  • 16-02-2005 09:55PM
    #1
    Registered Users, Registered Users 2 Posts: 94 ✭✭


    im just wondering if there is anyway to use the numbers generated by a random number generator to specify files.

    i.e.
    i have 10 files named 1.html, 2.html etc.. i also have the number generator generating integers between 1 and 10, what i would like is for the number generated to be used to specify a *.html file that will be opened in a frame...
    hope some one knows something that might help (i can't use server side scripting (at least i don't think i can))
    i this is unclear ill try and explain better if i can...


Comments

  • Registered Users, Registered Users 2 Posts: 8,452 ✭✭✭Time Magazine


    Easy peasy...

    //This will return you an integer between one and ten.
    var random_number = Math.round(Math.random()*10);


    //This should return random_number + ".html";
    random_number+=".html";


  • Registered Users, Registered Users 2 Posts: 94 ✭✭cmdrpaddy


    thanks, hope it works


Advertisement