Dropdown field value getting outputted multiple times I have a dropdown field that has three options. In my template, I want to do one thing if option 1 is selected and do something else if option 2 is selected.

Here is what my code looks like:

{% for option in entry.transparentMenu.options %}
    {% if entry.transparentMenu.value == "menuLight" %}
        &lt;h3&gt;white&lt;/h3&gt;
    {% elseif entry.transparentMenu.value == "menuDark" %}
        &lt;h3&gt;black&lt;/h3&gt;
    {% endif %}
{% endfor %}


The code seems to work but the output is: black black black; I only want black to display once.

What am I doing wrong?
You don't need the for loop in this case. What's happening is you're looping over each option in your dropdown field, and each time it's checking the value of the dropdown and displaying white or black. Since you have three options, you're going to get the dropdown value displayed three times (which is why you're seeing black black black).

All you need is just the if conditional:

{% if entry.transparentMenu.value == "menuLight" %}
    &lt;h3&gt;white&lt;/h3&gt;
{% elseif entry.transparentMenu.value == "menuDark" %}
    &lt;h3&gt;black&lt;/h3&gt;
{% endif %}



  Also, fwiw looks like you have a typo in your code ️ - you use entry.transparentMenu twice and entry.header.transparentMenu once. I'm guessing you want entry.transparentMenu everywhere...


The only time you'd want to use the for loop to get all the dropdown field's options is if you wanted to display those in the template (in a list for example or to create your own dropdown on the frontend):

&lt;ul&gt;
    {% for option in entry.dropdownFieldHandle.options %}
        &lt;li&gt;{{ option }}&lt;/li&gt;
    {% endfor %}
&lt;/ul&gt;


But in your case, you just want the current value and not all the options, so just remove the for loop.