Nasıl rastgele toplam olası 10 üzerinden 3 divs görüntülerim?
Bu şimdiye kadar denedim budur:
HTML:
<div id="1">Content 1</div>
<div id="2">Content 2</div>
<div id="3">Content 3</div>
<div id="4">Content 4</div>
<div id="5">Content 5</div>
<div id="6">Content 6</div>
Javascript:
function randomiseDiv()
{
      // Define how many divs we have
      var divCount = 6;
      // Get our random ID (based on the total above)
      var randomId = Math.floor(Math.random()*divCount+1);
      // Get the div that's been randomly selectted
      var chosenDiv= document.getElementById(randomId);
      // If the content is available on the page
      if (chosenDiv)
      {
            // Update the display
            chosenDiv.style.display = 'block';
      }
}
window.onload = randomiseDiv;
Bu aşamada herhangi bir şey yararlı olacaktır ancak ben, bir PHP çözümü tercih ederim.
 
			