title: Bind function to submit event
body: <p>I´m trying to bind a simple function to a submit event, that: </p>
  
  <ol>
  <li>Retrieves the values of all input fields </li>
  <li>Sets the action attribute of the form</li>
  <li>Submits the form</li>
  </ol>
  
  <p>Inspired by <a href="https://stackoverflow.com/questions/5049614/jquery-target-blank-atr-where-to-include-this-in-the-script/5049634#5049634">this answer</a> - I came up with the following code: </p>
  
  <pre><code>$(document).ready(function() {
      $('#fbook').bind('submit', function(event) {
          event.preventDefault();
          var baseURL = $(this).children('#base').val();
          var hotelID = $(this).children('#destination').val();
          var dateIn = $(this).children('#show-date-in').val();
          var location = baseURL + "&amp;hotelID=" + hotelID + "&amp;dateIn=" + dateIn;
          $(this).attr('action', location);
          $(this).submit();
      });
  });
  </code></pre>
  
  <p>And here´s the jsFiddle with HTML and JS: <a href="http://jsfiddle.net/mattvic/2wRHc/47/" rel="nofollow noreferrer">http://jsfiddle.net/mattvic/2wRHc/47/</a></p>
  
  <p>Unfortunately it doesn´t work and I just can´t see where I went wrong. I hope someone can spot the error. </p>
  
  <p>Many thanks!</p>