I'm working on a page that has a dropdown menu that gets populated from a database query. I also have an incoming parameter that, if it's populated, will match one of the options in the dropdown. If that parameter is populated, I want the option in the drowpdown to be selected. My instinct is to do something like the following (where foo is an entry in a FOREACH):
<% IF param -eq foo %>
<option value="foo" selected="selected">foo</option>
<% ELSE %>
<option value="foo">foo</option>
<% END %>
The problem is that I get an error that foo is an unrecognized token.
I can't find any evidence in documentation or examples that I can actually use the param -eq foo construct above. The examples I can find of IF statements don't use comparative operators. They basically only read a boolean parameter or check that a parameter has a value. But since it doesn't reject the -eq token, I've been holding out hope that there's a way to do it and that I just haven't figured out the right syntax or found the documentation yet.
Aucun commentaire:
Enregistrer un commentaire