SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Nov 2006
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to make a single serving site like http://barackobamaisyournewbicycle.com/?

    Hi all,

    I'd like to make a site like Barack Obama Is Your New Bicycle. Basically, I have a bunch of lines that I want to be able to set up so that when someone clicks on the link, it displays another entry randomly. Could someone point me in the direction of a tutorial on how to do this? I have a lot of experience making and administering websites, but I"m a noob at javascript. Thanks a bunch!

  2. #2
    SitePoint Zealot Gar onn's Avatar
    Join Date
    Feb 2011
    Location
    Belgium
    Posts
    130
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    make an array of them and then select one with the index floor(Math.random()*arr.length)

    javascript random array element

    first tut i found: JavaScript array get elements at random


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •