-1

If i have 10 divs and i want to choose 5 of them randomly and display them in a random order, how can i do that?

This is what im currently using: http://www.dynamicdrive.com/dynamicindex17/randomcontentorder.htm

2 Answers2

1

Put the ten divs in an array, shuffle the array, and show the first five.

Guffa
  • 687,336
  • 108
  • 737
  • 1,005
0

You can name your divs some kind like myDiv_0 to myDiv_9. Then you can generate random numbers between with JavaScript using var randomnumber=Math.floor(Math.random()*10). And after that you can get your div by window.getElementById('myDiv_' + randomnumber).

Chris
  • 7,675
  • 8
  • 51
  • 101