mylox
mylox

Reputation: 71

Pass Multiple Query String in Python

So, I'm building a web app using flask/jinja and I have a webpage that displays a list of data that includes date, and I currently have two drop down menus, one that controls the date range of data viewed and the other that sorts the data based on various parameters.

<form method='get' action=''>
    <button class='btn btn-default'>View data from:</button>
    <select name = "time_length">
      <option value="0">All</option>
      <option value="7">Week</option>
      <option value="30">Month</option>
    </select>
  </form>
</div>
<div>
  <form method='get' action=''>
    <button class='btn btn-default'>sort:</button>
    <select name = "sortby">
      <option value="user">Name</option>
      <option value="group">Project</option>
      <option value="date">Date</option>
    </select>
  </form>

Individually, this works fine because the it just passes along ?time_length=7 or whatever to the url, but I can't figure out how to pass along both parameters. One ends up replacing the other in the link.

Upvotes: 0

Views: 125

Answers (1)

rvictordelta
rvictordelta

Reputation: 668

You need to have them sent from the same <form>.

<form method='get' action=''>
  <button class='btn btn-default'>submit</button>
  <select name = "time_length">
    <option value="0">All</option>
    <option value="7">Week</option>
    <option value="30">Month</option>
 </select>

  <select name = "sortby">
    <option value="user">Name</option>
    <option value="group">Project</option>
    <option value="date">Date</option>
  </select>
</form>

Upvotes: 1

Related Questions