title: generate random string for div id
body: <p>I want to display YouTube videos on my website, but I need to be able to add a unique <code>id</code> for each video that's going to be shared by users. So I put this together, and I have run into a little problem. I am trying to get the JavaScript to add a random string for the div <code>id</code>, but it's not working, showing the string:</p>
  
  <pre><code>&lt;script type='text/javascript' src='jwplayer.js'&gt;&lt;/script&gt;
  &lt;script type='text/javascript'&gt;
  function randomString(length) {
      var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'.split('');
  
      if (! length) {
          length = Math.floor(Math.random() * chars.length);
      }
  
      var str = '';
      for (var i = 0; i &lt; length; i++) {
          str += chars[Math.floor(Math.random() * chars.length)];
      }
      return str;
  }
  
  var div = randomString(8);
  &lt;/script&gt;
  
  &lt;div id='div()'&gt;This text will be replaced&lt;/div&gt;
  
  &lt;script type='text/javascript'&gt;
    jwplayer('div()').setup({
      'flashplayer': 'player.swf',
      'file': 'http://www.youtube.com/watch?v=4AX0bi9GXXY',
      'controlbar': 'bottom',
      'width': '470',
      'height': '320'
    });
  &lt;/script&gt;
  </code></pre>