title: Using Javascript to pass a parameter from a URL to a hidden form field
body: <p>I wasn to be able to pass and ID such as '123456' from a URL:</p>
  
  <p><a href="http://www.mysite.com/page.html?ID=123456" rel="nofollow">http://www.mysite.com/page.html?ID=123456</a></p>
  
  <p>to a hidden form field.</p>
  
  <p>I found a Javascript that lets me write the ID to a page but I don't know how to add the value to the value="" bit of a hidden input field.</p>
  
  <p>Any ideas much appreciated!</p>
  
  <p>The JS I am using is:</p>
  
  <pre><code>&lt;script&gt; 
  function getQueryVariable(variable) { 
    var query = window.location.search.substring(1); 
    var vars = query.split("&amp;"); 
    for (var i=0;i&lt;vars.length;i++) { 
      var pair = vars[i].split("="); 
      if (pair[0] == variable) { 
        return pair[1]; 
      }
    } 
    alert('Query Variable ' + variable + ' not found'); 
  }   
  &lt;/script&gt;
  </code></pre>