1

I'm using Dynamic Parameters to filter through some channels https://ellislab.com/expressionengine/user-guide/add-ons/channel/dynamic_parameters.html

Is there a way to get the chosen select value to stay selected rather than it default back to the first option (All Tours in my case) after posting.

<form method="post" action="{path='template/{segment_2}'}">
          <input type="hidden" name="csrf_token" value="{csrf_token}" />
              <select name="channel">
                  <option value="llanelly-house-tour|restoration-tour|ghostly-tour">All Tours</option>
                  <option value="llanelly-house-tour">Llanelly House Tour</option>
                  <option value="restoration-tour">Restoration Tour</option>
                  <option value="ghostly-tour">Ghostly Tour</option>
              </select>
    </div>
    <div class="small-2 columns">
    <input role="button" aria-label="Submit" name="submit" type="submit" class="button postfix submit" value="Go" />
    </form>
1

Couple of options here.

You could use Mo' Variables to get to the {post:channel} variable and use that in a conditional to add the selected attribute to your options.

You could also use Dynamo, which offers even more functionality for dynamic parameters.

If you want to go all out, choosing a proper search/filtering add-on would be the way to go. Options are Solspace Super Search or Low Search by yours truly.

  • Perfect thank you Low, plenty of options :) – MBM Feb 20 '15 at 19:00
  • 1
    Go Low Like A Pro. – foamcow Feb 21 '15 at 11:27
1

Thanks Low! Mo Variables worked perfectly. I used the following to select the post channel:

 <form method="post" action="{path='tour-calendar/{segment_2}'}">
          <input type="hidden" name="csrf_token" value="{csrf_token}" />
              <select name="channel">
                  <option {if post:channel == "a|b|c"} selected="selected"{/if} name="channel" value="a|b|c">All Tours</option>
                  <option {if post:channel == "a"} selected="selected"{/if} name="channel" value="a">Llanelly House Tour</option>
                  <option {if post:channel == "b"} selected="selected"{/if} name="channel" value="b">Restoration Tour</option>
                  <option {if post:channel == "c"} selected="selected"{/if} name="channel" value="c">Ghostly Tour</option>
              </select>
    </div>
    <div class="small-2 columns">
    <input role="button" aria-label="Submit" name="submit" type="submit" class="button postfix submit" value="Go" />
    </form>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.