title: attach jquery array to form submit
body: <p>I am using the following to submit a form on button click.  I need to attach an array named 'selected' to this post as well.  I cannot use ajax for this because there will be a download happening on the posting page.  I need this array to process the file to be downloaded.</p>
  
  <p>I did some searching and came upon this, but was not able to get it working either :</p>
  
  <pre><code>var input = $("&lt;input&gt;").attr({"type":"hidden","name":"selected"}).val(selected);
  $('#test').append(input);
  </code></pre>
  
  <p>Current :</p>
  
  <pre><code>var selected = [1,2,54,56,23]; // could be anything
  
  $('#test').submit(function(event) {
      if (selected.length &gt; 0)
      {
          $('#test').attr('action','/process/p_screenshots_download2.php');
          $('#test').attr('type','post');
          return;
      }
      event.preventDefault();
  });
  </code></pre>