title: I want to pass a value from search query to hidden field
body: <p>I have a live search form on the site that does two things. If it gets any results it displays them, and if not, the visitor can send an email. </p>
  
  <p>There are two input type fields</p>
  
  <pre><code>&lt;input type="hidden" name="myField" id="myField" value="" /&gt;
  Email: &lt;input name="email-index" id="email-index" type="text" /&gt;&lt;/b&gt;
  </code></pre>
  
  <p>In the email field, the visitor inputs the email. And in the value of the hidden field, i want the search query to be passed from the query. </p>
  
  <p>The search query results are displayed one div before this form with</p>
  
  <pre><code>&lt;!-- Results --&gt;
          &lt;h4 id="results-text"&gt; &lt;b id="search-string"&gt;&lt;/b&gt;&lt;/h4&gt;
  </code></pre>
  
  <p>where search-string is replaced with the query. </p>
  
  <p>I have put this into <strong>jquery</strong></p>
  
  <pre><code>var hidden = "search-string";
  $('input[name=myField]').val(hidden);
  </code></pre>
  
  <p>but nothing really happens, i get an empty output.</p>
  
  <p>Thank you for your help!</p>