Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Random Numbers in javascript

Options
  • 16-02-2005 9:55pm
    #1
    Registered Users 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 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 Posts: 94 ✭✭cmdrpaddy


    thanks, hope it works


Advertisement