I am using WordPress 3..5 on Dreamhost, trying to produce a text widget within the sidebar which will show a random group of nine (9) client logos. You will find a maximum of 12 logos, situated within the /wordpress-content/clients folder, named logo1.digital through logo12.digital.

The concept is to find the first image at random, then obtain the next eight images in consecutive to avoid replicates.

UPDATE

First got it working, just tips everybody!

This is actually the final, working version:

<div id="client-logos"></div>

<script type="text/javascript">

TotalLogos = 12;    
FirstPart = '<img src="/wp-content/clients/logo';
LastPart = '.jpg" height="50" width="110" />';

var r = Math.ceil(Math.random() * TotalLogos);

var content = document.getElementById('client-logos').innerHTML;
document.getElementById('client-logos').innerHTML = FirstPart + r + LastPart;

var t=0;
for (t=0;t<8;t++)
   {
      if (r == TotalLogos) { r=0; }
      r++;
      var content = document.getElementById('client-logos').innerHTML;
      document.getElementById('client-logos').innerHTML = content + FirstPart + r + LastPart;
   }

</script>

document.write() runs prior to the page finishes loading.. you need to use another thing..

to begin with, you need to get object of the div container by id:

your html:

    <div id="containerid"></div>

<script>
var elem = document.getElementById('containerid');
elem.innerHTML= "FirstPart + r + LastPart";
</script>

Just change t=8 to t<8 and delay pills work (for me personally). The 2nd expression inside a for loop means: "Execute the foor loop as lengthy because this is true". Your code needs to be performed as lengthy as t < 8 when t == 8, it will stop.

Working example: http://jsfiddle.net/m7m7C/