How to make website shuffle links?

Discussion in 'HTML & Website Design' started by augentier, Sep 19, 2013.

  1. #1
    Hey, I'm kinda new to web design. I know basic HTML and CSS but I'm having trouble with the more advanced stuff. I want to make my thumbnail image links shuffle each time the page is refreshed, like on this website: www.thestupidstation.com

    On that site, every time you click on something (like the previous/next buttons on the specific topic pages), their thumbnail links on the side changes or shuffles. How can I make my site do that?
     
    augentier, Sep 19, 2013 IP
  2. competent123

    competent123 Notable Member

    Messages:
    1,752
    Likes Received:
    71
    Best Answers:
    6
    Trophy Points:
    255
    #2
    if you are using wordpress, you can use random widget
    if you are using plain php, then you can put it within a random array and display it there

    Regards
     
    competent123, Sep 19, 2013 IP
  3. augentier

    augentier Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #3
    I am not using wordpress...i'm using Dreamweaver to construct the website using HTML and CSS. I don't understand PHP...at all.
     
    augentier, Sep 19, 2013 IP
  4. competent123

    competent123 Notable Member

    Messages:
    1,752
    Likes Received:
    71
    Best Answers:
    6
    Trophy Points:
    255
    #4
    <script type="text/javascript">
    var textarray = [
    "hi",
    "hello",
    "how r u",
    "where r u" // No comma after last entry
    ];
    
    function RndText() {
    var rannum= Math.floor(Math.random()*textarray.length);
    document.getElementById('ShowText').innerHTML=textarray[rannum];
    }
    onload = function() { RndText(); }
    
    var inter = setInterval(function() { RndText(); }, 2000);
    
    </script>
    PHP:
    this will be enough for you - its javascript

    put this at the relevant section on webpage
     
    competent123, Sep 19, 2013 IP
  5. augentier

    augentier Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #5
    Thank you...do I need to change any of that text above and replace it with something else..if so , what?
     
    augentier, Sep 19, 2013 IP
  6. competent123

    competent123 Notable Member

    Messages:
    1,752
    Likes Received:
    71
    Best Answers:
    6
    Trophy Points:
    255
    #6
    2000 - delay
    the text you wish to display - hi,hello , how are you etc.

    rest is standard
     
    competent123, Sep 19, 2013 IP
  7. augentier

    augentier Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #7
    So if I want a bunch of image links to shuffle, I put <a href="whatever.html"><img src="image.gif" /></a> in the place of hi, hello, etc..?

    and I put this script in the head element or in the div where those links are contained?

    I know I ask a lot of questions lol..just want to make sure I am understanding correctly.
     
    augentier, Sep 20, 2013 IP
  8. competent123

    competent123 Notable Member

    Messages:
    1,752
    Likes Received:
    71
    Best Answers:
    6
    Trophy Points:
    255
    #8
    instead of asking, the best way is to implement - try , change, try , change, until you get what you want.

    Thats how i learned everything i ever knew.
     
    competent123, Sep 20, 2013 IP
  9. augentier

    augentier Peon

    Messages:
    12
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #9
    Yeah, I realize that. It would be nice to know specifics, though..so I'm not pasting that code in every possible place in my coding. A more thorough explanation is always more helpful.
     
    augentier, Sep 20, 2013 IP