Using routes for get method

Hey :slight_smile:

I’m wondering what the best way of changing a URL when a form is submitted.

For example if I had multiple select fields with various options how could I change the URL depending on what option has been selected? Is this possible?

    <form method="get" action="">
          <select name="option1">
                <option value="one">One</option>
                <option value="two">Two</option>
                <option value="three">Three</option>
                <option value="four">Four</option>
          </select>
          <select name="option2">
                <option value="one">One</option>
                <option value="two">Two</option>
                <option value="three">Three</option>
                <option value="four">Four</option>
          </select>
     </form>

What I’m wondering is if both select boxes are submitted if the URL could be changed to show

     ../one/three/

Been puzzling me for a little bit - can this be done?

Thanks :slight_smile:

It depends on how you process the form. If you use a route that gets called with the form results, you can use something like this:

go('../' . get('option1', 'defaultvalue') . '/' . get('option2', 'defaultvalue'));