select an option within an optgroup
<p>I am trying to select an option in a select menu that contains an optgroup. I have tried 
<code>document.getElementsByName("dob_year")[0].selectedIndex = "1980";</code> and it seems to work with select menus that contain no "optgroups", bit it does work with them. How can I select the "1980" option?</p>

<pre><code>&lt;select name="dob_year"&gt; 
    &lt;optgroup label="Morning"&gt; 
        &lt;option value="1980"&gt;80&lt;/option&gt; 
        &lt;option value="1981"&gt;81&lt;/option&gt; 
        &lt;option value="1982"&gt;82&lt;/option&gt; 
        &lt;option value="1983"&gt;83&lt;/option&gt; 
    &lt;/optgroup&gt; 
&lt;/select&gt; 
</code></pre>
