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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Random Numbers in javascript

  • 16-02-2005 8: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