Answers.Body: <p>If your goal is to filter by one drop-down value at a time then you could use an if statement to check if the passed value is set for each drop-down.  This will only work if each drop-down has an option that is blank or it submits on select so that the other drop-down is not set.</p>
  
  <pre><code>{% set query = "" %}
  {% if craft.request.getParam('country1') and 
        craft.request.getParam('country1') is not empty %}
      {% set query = craft.request.getParam('country1') %}
  {% elseif craft.request.getParam('development1') and 
            craft.request.getParam('development1') is not empty %}
      {% set query = craft.request.getParam('development1') %}
  {% endif %}
  
  {% for category in queryFilter %}
  
  ....markup...
  
  {% endfor %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-16T15:32:36.933Z
Answers.Text: Excellent, that has it working, but only if I turn off dev mode as in dev mode it says `Variable "query" does not exist` So is there any ideas how to fix that? If not I can just turn off dev mode.
Answers.UserDisplayName: mention79
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-16T15:33:36.437Z
Answers.Text: I have updated the answer
Answers.UserDisplayName: a-am
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-16T15:19:29.733Z
Answers.LastActivityDate: 2017-01-16T15:33:29.573Z
Answers.LastEditDate: 2017-01-16T15:33:29.573Z
Answers.UserDisplayName: a-am
Body: <p>I have a multiple dropdown filters that lets users pick the category that they want to display results for below. See my previous question <a href="https://craftcms.stackexchange.com/questions/18523/search-entries-by-location-or-name">Search entries by location or name</a> for screenshot.</p>
  
  <p>So I have one working, but I need some guidance on how to do the code for the other filters as well, as currently my code for linking up to the second filter is stopping the first filter from working correctly. So clearly I'm doing it wrong. </p>
  
  <p>So I have four dropdown filters, but I'll simplify it to two filters for this example. The filters are named <code>name="county1"</code> and <code>name="development1"</code> in their respective  tags.</p>
  
  <p>And then I'm using the following to access them:</p>
  
  <pre><code>{% set query = craft.request.getParam('county1') %}
  {% set query = craft.request.getParam('development1') %}
  {% set queryFilter = craft.categories.group('developments').search(query).order('title asc') %}
  
  {% for category in queryFilter %}
  
  ....markup...
  
  {% endfor %}
  </code></pre>
  
  <p>Can someone tell me what i need to do to fix this so that the filters don't interfere with each other?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-16T04:29:25.303Z
Comments.Text: Are you trying to filter for a category or entries based on a category selected?  Does your drop-downs contain categories from the group 'developments'?
Comments.UserDisplayName: a-am
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-16T09:23:45.290Z
Comments.Text: The first dropdown holds categories from a category group called counties and the second dropdown holds categories from a category group called developments. The filters themselves are showing the correct data and the first dropdown is creating the right results when selected, but the problem I'm having is that the second dropdown is not outputting the correct results. So I'm assuming the line `{% set query = craft.request.getParam('development1') %}` and possibly that I need to set a second queryFilter row with different name?
Comments.UserDisplayName: mention79
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-16T15:10:35.070Z
Comments.Text: Are you trying to filter by both at the same time or just one filter at a time?
Comments.UserDisplayName: a-am
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-01-16T15:12:31.483Z
Comments.Text: just one at a time is all I need
Comments.UserDisplayName: mention79
Tags: <search><request><query>
Title: Multiple dropdown filters interfering with each other
ThreadText: # Multiple dropdown filters interfering with each other
  
  (Asked by: username_0 on 2017-01-15)
  
  I have a multiple dropdown filters that lets users pick the category that they want to display results for below. See my previous question [Search entries by location or name](https://craftcms.stackexchange.com/questions/18523/search-entries-by-location-or-name) for screenshot.
  
  So I have one working, but I need some guidance on how to do the code for the other filters as well, as currently my code for linking up to the second filter is stopping the first filter from working correctly. So clearly I'm doing it wrong.
  
  So I have four dropdown filters, but I'll simplify it to two filters for this example. The filters are named `name="county1"` and `name="development1"` in their respective tags.
  
  And then I'm using the following to access them:
  
  ```
  {% set query = craft.request.getParam('county1') %}
  {% set query = craft.request.getParam('development1') %}
  {% set queryFilter = craft.categories.group('developments').search(query).order('title asc') %}
  
  {% for category in queryFilter %}
  
  ....markup...
  
  {% endfor %}
  
  ```
  
  Can someone tell me what i need to do to fix this so that the filters don't interfere with each other?
  
  **Tags:** search, request, query
  
  > **Comments:**
  > **username_1**: Are you trying to filter for a category or entries based on a category selected?  Does your drop-downs contain categories from the group 'developments'?  
  > **username_0**: The first dropdown holds categories from a category group called counties and the second dropdown holds categories from a category group called developments. The filters themselves are showing the correct data and the first dropdown is creating the right results when selected, but the problem I'm having is that the second dropdown is not outputting the correct results. So I'm assuming the line `{% set query = craft.request.getParam('development1') %}` and possibly that I need to set a second queryFilter row with different name?  
  > **username_1**: Are you trying to filter by both at the same time or just one filter at a time?  
  > **username_0**: just one at a time is all I need  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-01-16. Score: 1 | Accepted answer
  
  If your goal is to filter by one drop-down value at a time then you could use an if statement to check if the passed value is set for each drop-down. This will only work if each drop-down has an option that is blank or it submits on select so that the other drop-down is not set.
  
  ```
  {% set query = "" %}
  {% if craft.request.getParam('country1') and 
        craft.request.getParam('country1') is not empty %}
      {% set query = craft.request.getParam('country1') %}
  {% elseif craft.request.getParam('development1') and 
            craft.request.getParam('development1') is not empty %}
      {% set query = craft.request.getParam('development1') %}
  {% endif %}
  
  {% for category in queryFilter %}
  
  ....markup...
  
  {% endfor %}
  
  ```
  
  > **Comments:**
  > **username_0**: Excellent, that has it working, but only if I turn off dev mode as in dev mode it says `Variable "query" does not exist` So is there any ideas how to fix that? If not I can just turn off dev mode.  
  > **username_1**: I have updated the answer  
  
  ---
  
  