Loop through entry titles in a select field Im trying to use entry titles as options in a select field, similar to the last example on this page in the docs

My code looks like this:

&lt;label&gt;Position Applying For&lt;/label&gt;
&lt;select name="{{ positionApplyingFor.handle }}"&gt;
{% for entry in craft.entries.section('careers') %}
  &lt;option value="{{ entry.title }}"&gt;
    {{ entry.title }}
  &lt;/option&gt;
{% endfor %}
&lt;/select&gt;


Although the form submits, the fields content is not shown in the admin.

If I add {% if field.value == entry.handle %} selected{% endif %}, I get the error "Variable "field" does not exist"

Any help appreciated!

Martin
The issue is you don't have a variable named input. I changed the code a little by included a variable named value. To make sure the proper option is selected you would need to pass back to the template a url param name with the currently selected option value.  If there is a param and it has a value it will add that value to the variable value if not value will be blank.

&lt;label&gt;Position Applying For&lt;/label&gt;
{% set value = craft.request.getParam("name")?? "" %}
&lt;select name="{{ positionApplyingFor.handle }}"&gt;
    {% for entry in craft.entries.section('careers') %}
        &lt;option value="{{ entry.title }}" {% if value == entry.title %}selected{% endif %}&gt;
            {{ entry.title }}
        &lt;/option&gt;
    {% endfor %}
&lt;/select&gt;