display JS random number inside url?

by danb12
4 replies
Can anyone show me away to show a random number inside a url? be in image or link?

eg:

Code:
<img src="img/+"randomNumber"+.png>
thanks :confused::confused:
#display #inside #number #random #url
  • Profile picture of the author Brandon Tanner
    If you only need 1 random number per page load, then it'd be best to use PHP for this.

    <img src="img/<?php echo(rand(10,100)); ?>.png">

    In the example above, 10 represents the lowest random number you want returned, and 100 represents the highest. But you can change those numbers to whatever you want.
    Signature

    {{ DiscussionBoard.errors[7870682].message }}
  • Profile picture of the author danb12
    Thanks,

    it works, its working multiple times which is great, however its showing duplicate numbers.. anyway to show unique numbers?

    cheers.
    Signature
    UK Coupon Website PR1 making £300+ per month - QUICK SALE - CHEAP SALE - CONTACT ME
    {{ DiscussionBoard.errors[7870720].message }}
    • Profile picture of the author Brandon Tanner
      What do you mean by "duplicate" numbers?
      Signature

      {{ DiscussionBoard.errors[7870828].message }}
  • Profile picture of the author SmallBizWebsites
    You don't really want a random number if it must be unique. Any random number generator will repeat a given number eventually. Why not keep a little file on the server and add 1 to the value each time you need a number? That way the number will always be unique and never repeat.
    {{ DiscussionBoard.errors[7872001].message }}

Trending Topics