Setting a SELECT element by text, not value
<p>I'm sure this is relatively easy and straightforward, but I'm having no success figuring it out.</p>

<p>I am trying to set the selected option of a drop down list element using the following code:</p>

<pre><code>        if ($(this).attr("tagName") == "SELECT") {

            oldValue = $(this).parent().parent().find('span.displayField').text();
            $(this).val(oldValue).attr("selected", "selected");
            return;
        }
</code></pre>

<p>But it is not changing the select element at all.  The code is definitely running, and <code>oldValue</code> is being populated appropriately.</p>

<p>Can anyone see what I might be missing?</p>

<p>Thanks!</p>

<p>UPDATE:</p>

<p>For clarification, here is the HTML:</p>

<pre><code>        &lt;span class="displayField"&gt;Pending&lt;/span&gt;
        &lt;span class="editField"&gt;            
            &lt;select data-val="true" data-val-number="The field ProgramStatusId must be a number." data-val-required="The ProgramStatusId field is required." id="ProgramListViewModels_0__ProgramStatusId" name="ProgramListViewModels[0].ProgramStatusId"&gt;
            &lt;option value="1"&gt;Pending&lt;/option&gt;
            &lt;option value="2"&gt;Tabled&lt;/option&gt;
            &lt;option value="3"&gt;Approved&lt;/option&gt;
            &lt;option value="4"&gt;Declined&lt;/option&gt;
            &lt;/select&gt;  
        &lt;/span&gt;
</code></pre>
