Note that there are some explanatory texts on larger screens.

plurals
  1. PORemember Dropdown Selection
    text
    copied!<p>I've got a few select lists on my form which look a bit like this:</p> <pre><code>&lt;option value="400000" &lt;?php if($_GET['MaxPrice'] == "400000") { echo("selected"); } ?&gt;&gt;&amp;pound;400,000&lt;/option&gt; </code></pre> <p>As you can see (above) I've got a bit of PHP in there telling the form to remember it's selection upon submit.</p> <p>Is there a short bit of PHP that would remember every selection without the rather heavy method I'm using above?</p> <p>Thanks in advance.</p> <p>UPDATE:</p> <pre><code>&lt;select name="MaxPrice" id="MaxPrice"&gt; &lt;option value="9999999" selected&gt;Price (Max)&lt;/option&gt; &lt;option value="100000" &lt;?php if($_GET['MaxPrice'] == "100000") { echo("selected"); } ?&gt;&gt;&amp;pound;100,000&lt;/option&gt; &lt;option value="200000" &lt;?php if($_GET['MaxPrice'] == "200000") { echo("selected"); } ?&gt;&gt;&amp;pound;200,000&lt;/option&gt; &lt;option value="300000" &lt;?php if($_GET['MaxPrice'] == "300000") { echo("selected"); } ?&gt;&gt;&amp;pound;300,000&lt;/option&gt; &lt;option value="400000" &lt;?php if($_GET['MaxPrice'] == "400000") { echo("selected"); } ?&gt;&gt;&amp;pound;400,000&lt;/option&gt; &lt;/select&gt; </code></pre> <p>UPDATE 2: Is there a way to implement this technique into some JavaScript?</p> <pre><code>if (BuyRent=='buy') document.SearchForm.MaxPrice.options[9999999]=new Option("Price (Max)","150000000"); document.SearchForm.MaxPrice.options[100000]=new Option("\u00A3100,000","100000"); document.SearchForm.MaxPrice.options[200000]=new Option("\u00A3200,000","200000"); document.SearchForm.MaxPrice.options[300000]=new Option("\u00A3300,000","300000"); document.SearchForm.MaxPrice.options[400000]=new Option("\u00A3400,000","400000"); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload