I have a link leading to 1 of 6 articles displaying on my website. Every 6 seconds, the text link switches to the next. I'd like for the order to be randomized, though, so that each article has the same likelihood to be chosen. Can anyone help?

My code on gist is here:
https://gist.github.com/jonsan32/5982135

The raw code is here:
https://gist.github.com/jonsan32/5982135/raw/4952a61f968cfa372bdebe9a81d97c75456526a4/gistfile1.txt

Thank you in advance.

Recommended Answers

Instead of index++ use the Math.random() function. But you should try to avoid the same number being chosen again.

Jump to Post

All 2 Replies

Instead of index++ use the Math.random() function. But you should try to avoid the same number being chosen again.

Sounds simple enough, but I have no clue what you're talking about. I should've mentioned that I suck at coding. I'm just good at googling stuff to copy and paste. What should I search for to find a tutorial? Would it be hard to actually implement?

Thank you for the response either way. I truly appreciate it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.