title: Flask - pass form input to url_for
body: <p>I have an HTML template that lets the user select a date via jQuery datepicker.</p>
  
  <p>How can I pass the date selected into an action?</p>
  
  <p>The idea is, the user selects a date, then that passes to Flask's route.py, via <code>app.route("/date/&lt;date&gt;")</code></p>
  
  <p>calendar.html</p>
  
  <pre><code>{% block topscripts %}
      &lt;link rel="stylesheet" type="text/css" href= "{{ url_for('static',filename='styles/calendar.css') }}"&gt;
      &lt;script&gt;
          $(function() {
              $("#datepicker").datepicker({dateFormat: 'yy-mm-dd'});
          });
      &lt;/script&gt;    
  {% endblock %}
  
  {% block content %}
  &lt;form method="post" action="{{ url_for('specific_date', date='2019-04-11') }}"&gt;
  &lt;p&gt;Date: &lt;input type="text" id="datepicker"  name='go-to-date'&gt;&lt;/p&gt;
      &lt;input type="hidden" name="calendar-form"&gt;
      &lt;input type="submit"&gt;
  &lt;/form&gt;
  {% endblock %}
  </code></pre>
  
  <p>So, when the user selects a date in the <code>datepicker</code> ID, I want to pass that date to the <code>url_for</code>.  Currently I hardcoded the date (<code>2019-04-11</code>) just to check that it works, and it does.  How can I have that part be dynamic to whatever the user selects in the Calendar?  </p>
  
  <p>...If it helps, here's in routes.py (<code>default_template()</code> is the function that renders the template in the end).:</p>
  
  <pre><code>@app.route("/date/&lt;date&gt;/", methods=["GET", "POST"])
  def specific_date(date):
      print("\n\nDate:", date, "\n\n")
      images = get_files_on(date)
      print("\n\nSpecific date images:", images)
      return default_template(date=date, image_list=images)
  </code></pre>