how to use a random generator in html file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • neha2srivastava
    New Member
    • Aug 2008
    • 2

    how to use a random generator in html file

    Hi friends,
    I want to open a file..from around 10 numbered files present 1 to 10... in random order each time i click on the link present in an html file,

    For e.g
    let the files which i want to open be f1,f2,...f10

    i want to write such a function in html so that different files open at different clicks on the link present in the html file.
    <A HREF="f*.pdf">m yfile</A>

    where * lies between 1 to 10.. and any file from f1 to f10 opens on clicking on the hyperlink myfile(i.e randomly generated file)

    thanks for your time
  • eWish
    Recognized Expert Contributor
    • Jul 2007
    • 973

    #2
    Welcome to Bytes.com neha2srivastava !


    You will either need a server-side language or JavaScript. HTML will not be able to do this for you. It is merely a markup language not necessarily a programming language. However you end up achieving your desired result just have it print the HTML needed for the link to be random as you wish.

    --Kevin

    Comment

    • neha2srivastava
      New Member
      • Aug 2008
      • 2

      #3
      it would be great if you could let me know how this is done using java script.

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        To generate a number between 1 and 10, use this:
        [code=javascript]var randnum = Math.ceil(10*Ma th.random());[/code]
        PS. moved to the JavaScript forum.

        Comment

        Working...