title: How to choose a set of unique random numbers (no duplicates) using the jQuery.inArray method?
body: <p>This is a Javascript / jQuery question:</p>
  
  <p>I'm trying to generate six unique random numbers between 1 and 21 (no duplicates), using the <strong>jQuery.inArray</strong> method. Those six numbers will then be used to select six .jpg files from a group named logo1.jpg through logo21.jpg.</p>
  
  <p>Can anyone tell me what I'm doing wrong here?</p>
  
  <pre><code>&lt;div id="client-logos"&gt;&lt;/div&gt;
  
  &lt;script src="http://code.jquery.com/jquery-1.5.js"&gt;&lt;/script&gt;
  
  &lt;script type="text/javascript"&gt;
  
  Show = 6; // Number of logos to show
  TotalLogos = 21; // Total number of logos to choose from
  FirstPart = '&lt;img src="/wp-content/client-logos/logo';
  LastPart = '.jpg" height="60" width="120" /&gt;';
  r = new Array(Show); // Random number array
  
  var t=0;
  for (t=0;t&lt;Show;t++)
     {
        while ( jQuery.inArray(x,r)
           {
              var x = Math.ceil(Math.random() * TotalLogos);
           });
        r[t] = x;
        var content = document.getElementById('client-logos').innerHTML;
        document.getElementById('client-logos').innerHTML = content + FirstPart + r[t] + LastPart;
     }
  
  &lt;/script&gt;
  </code></pre>
  
  <p>Thanks in advance...</p>