Note that there are some explanatory texts on larger screens.

plurals
  1. POString replace with multiple dropdown search boxes
    primarykey
    data
    text
    <p>I have made a dropdown search option when visitors can select from several words and search for that.</p> <p>The problem is that with every word extra data is added.</p> <p>With one word it is</p> <pre><code>/?s=keyword </code></pre> <p>With 2 words it is</p> <pre><code>/?s=keyword&amp;sn=keyword2 </code></pre> <p>but it should be</p> <pre><code>/?s=keyword+keyword2 </code></pre> <p>The form is as followed</p> <pre><code>&lt;form role="search" method="get" id="searchform" action="&lt;?php bloginfo('siteurl'); ?&gt;"&gt; &lt;div&gt; &lt;label class="screen-reader-text" for="s"&gt;Search for:&lt;/label&gt; Type &lt;select name='s' id='type' class='postform' &gt; &lt;option value='' selected='selected'&gt;All&lt;/option&gt; &lt;option class="level-0" value="dog"&gt;Dog&lt;/option&gt; &lt;option class="level-0" value="cat"&gt;Cat&lt;/option&gt; &lt;/select&gt; Color &lt;select name='s' id='color' class='postform' &gt; &lt;option value='' selected='selected'&gt;All&lt;/option&gt; &lt;option class="level-0" value="red"&gt;red&lt;/option&gt; &lt;option class="level-0" value="white"&gt;white&lt;/option&gt; &lt;option class="level-0" value="green"&gt;green&lt;/option&gt; &lt;/select&gt; &lt;input type="submit" id="searchsubmit" value="Search" /&gt; &lt;/div&gt; &lt;/form&gt; </code></pre> <p>Is there a way to replace <strong>&amp;sn=</strong> with <strong>+</strong> ?</p> <p>I have tried</p> <pre><code>$_get = str_replace('&amp;sn=', '+', $_get); </code></pre> <p>But that didn't work.</p> <p>The working answer was given by Wgaffa and is, but it does not work with IE or Firefox :(</p> <pre><code>&lt;script type="text/javascript" charset="utf-8"&gt; function add_criteria (el) { search = document.getElementById('search_criteria'); search.value = document.getElementById('type').value + " " + document.getElementById('color').value; } &lt;/script&gt; &lt;form role="search" method="get" id="searchform" action="&lt;?php bloginfo('siteurl'); ?&gt;"&gt; &lt;label class="screen-reader-text" for="s"&gt;Search for:&lt;/label&gt; Type &lt;select name='' id='type' class='postform' onchange="add_criteria(this);"&gt; &lt;option value='' selected='selected'&gt;All&lt;/option&gt; &lt;option class="level-0" value="dog"&gt;Dog&lt;/option&gt; &lt;option class="level-0" value="cat"&gt;Cat&lt;/option&gt; &lt;/select&gt; Color &lt;select name='' id='color' class='postform' onchange="add_criteria(this);"&gt; &lt;option value='' selected='selected'&gt;All&lt;/option&gt; &lt;option class="level-0" value="red"&gt;red&lt;/option&gt; &lt;option class="level-0" value="white"&gt;white&lt;/option&gt; &lt;option class="level-0" value="green"&gt;green&lt;/option&gt; &lt;/select&gt; &lt;input type="hidden" id="search_criteria" value="" name="s" /&gt; &lt;input type="submit" id="searchsubmit" value="Search" /&gt; &lt;/div&gt; &lt;/form&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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