<p>If you've got a dropdown field defined with no value as one of the options, it should be as simple as:</p>

<pre><code>{% if entry.dropdownFieldHandle %}
    {{ entry.dropdownFieldHandle }}
{% endif %}
</code></pre>

CC BY-SA 3.0
2017-03-10T17:44:28.233Z
Thanks Brad.  I'm going to mark this as the correct answer because it does work.  However, it is showing content inside the {% if %} statement even if a value has been selected from the dropdown, which is strange.  No worries though, I am modifying my template to avoid that.
Todd
CC BY-SA 3.0
2017-03-10T06:32:12.943Z
2017-03-10T06:32:12.943Z
Brad Bell
<p>I've set up a dropdown field for the client to choose from a list of pre-defined addresses.  In my template, I want to determine whether the field has a value or not.  When I look in the database, Entry A has a value of 'NULL', while Entry B has a value of 'address1'.  So the field is working properly in those regards.</p>

<p>However, in my template it's all or nothing.  Here is my code:</p>

<pre><code>{% if event.includeMap|length %}
&lt;tr&gt;
    &lt;th class="small"&gt;
        Defined? {{ event.includeMap is defined }}&lt;br&gt;
        Not Null? {{ event.includeMap is not null }}&lt;br&gt;
        Null: {{ event.includeMap is null }}&lt;br&gt;
        Value: {{ event.includeMap }}
    &lt;/th&gt;
    &lt;td align="center"&gt;
        {% include 'partials/_inc-map' %}
    &lt;/td&gt;
&lt;/tr&gt;
{% endif %}
</code></pre>

<p>I've added the options in the left column to see what the database returns.  In both cases, they return the same values.  However, with Entry A, nothing is returned as a value, and in Entry B, the correct value appears.</p>

<p>I have also tried </p>

<pre><code>{% if event.includeMap is defined %}
{% if event.includeMap is not null %}
</code></pre>

<p>Any other thoughts?</p>

CC BY-SA 3.0
2017-03-10T01:09:09.330Z
How does your dropdown not have anything selected?  Do you have an empty label/value at the top or something and you consider that nothing selected?
Brad Bell
CC BY-SA 3.0
2017-03-10T05:04:33.637Z
I have the first option as a "Please Select...." with nothing as a value (which someone recommended in another post).  Am I better off adding a value of 0 or something and testing against that?
Todd
<templating>
Testing for Dropdown Value
# Testing for Dropdown Value

(Asked by: username_0 on 2017-03-09)

I've set up a dropdown field for the client to choose from a list of pre-defined addresses.  In my template, I want to determine whether the field has a value or not.  When I look in the database, Entry A has a value of 'NULL', while Entry B has a value of 'address1'.  So the field is working properly in those regards.
However, in my template it's all or nothing.  Here is my code:
{% if event.includeMap|length %}

    
        Defined? {{ event.includeMap is defined }}
        Not Null? {{ event.includeMap is not null }}
        Null: {{ event.includeMap is null }}
        Value: {{ event.includeMap }}
    
    
        {% include 'partials/_inc-map' %}
    

{% endif %}

I've added the options in the left column to see what the database returns.  In both cases, they return the same values.  However, with Entry A, nothing is returned as a value, and in Entry B, the correct value appears.
I have also tried 
{% if event.includeMap is defined %}
{% if event.includeMap is not null %}

Any other thoughts?

**Tags:** templating

> **Comments:**
> **username_1**: How does your dropdown not have anything selected?  Do you have an empty label/value at the top or something and you consider that nothing selected?  
> **username_0**: I have the first option as a "Please Select...." with nothing as a value (which someone recommended in another post).  Am I better off adding a value of 0 or something and testing against that?  

---

## 1 answers

### Answer by username_1 on 2017-03-10. Score: 4 | Accepted answer

If you've got a dropdown field defined with no value as one of the options, it should be as simple as:
{% if entry.dropdownFieldHandle %}
    {{ entry.dropdownFieldHandle }}
{% endif %}

> **Comments:**
> **username_0**: Thanks Brad.  I'm going to mark this as the correct answer because it does work.  However, it is showing content inside the {% if %} statement even if a value has been selected from the dropdown, which is strange.  No worries though, I am modifying my template to avoid that.  

---

