title: Fill in and submit form with link outside this form
body: <p>I would like to fill in <strong>and</strong> submit the follow form when clicking on a link outside the form, using the link's content.</p>
  
  <pre><code>&lt;%= form_tag search_path, url: search_path, remote: true do %&gt;
      &lt;div class='input-group'&gt;
          &lt;div class='search-box'&gt;
              &lt;%= text_field_tag 'query', nil, class: 'form-control typeahead', autocomplete: 'off' %&gt;
              &lt;/div&gt;
  
              &lt;span class='input-group-btn'&gt;
                  &lt;button type='button' class='btn btn-default' data-toggle='modal' data-target='#settingsmodal'&gt;
                      &lt;span class='glyphicon glyphicon-cog'&gt;&lt;/span&gt;
                  &lt;/button&gt;
                  &lt;%= submit_tag t('process.search'), id: 'search_button', class: 'btn btn-primary' %&gt;
              &lt;/span&gt;
          &lt;/div&gt;
          &lt;%= render 'settings_modal' %&gt;
  &lt;% end %&gt;
  
  ...
  
  &lt;a href="#"&gt;This text should be submitted&lt;/a&gt;
  </code></pre>
  
  <p>I tried to fill in the text field and click the button using jQuery, but this didn't work. I read about the jQuery submit() call, but can't figure out how to use it. Any help?</p>