title: Javascript set selected option
body: <p>I am trying to programmatically set a <code>&lt;select&gt;</code>'s option using the code below. The value is being set for the select, but the option is not reflecting it. Any help would be greatly appreciated.</p>
  
  <p>Set select value:</p>
  
  <pre><code>document.getElementById('cunit_usergroup').setAttribute('value', '3');
  </code></pre>
  
  <p>HTML:</p>
  
  <pre><code>&lt;select id="cunit_usergroup" class="input_select" tabindex="1" name="cunit_usergroup" value="3"&gt;
     &lt;option value="62"&gt;2nd Aviation Detachment&lt;/option&gt;
     &lt;option value="3"&gt;3rd Infantry Division&lt;/option&gt;
     &lt;option value="77"&gt;Alpha Company Headquarters&lt;/option&gt;
     &lt;option value="4"&gt;Alpha Company Leadership  &lt;/option&gt;
     &lt;option value="5"&gt;Banned&lt;/option&gt;
     &lt;option value="13"&gt;Base Maintenance Operations&lt;/option&gt;
     &lt;option value="9"&gt;Civillian&lt;/option&gt;
     &lt;option value="17"&gt;Combat Imaging and Development&lt;/option&gt;
     &lt;option value="10"&gt;Corps of Engineers  &lt;/option&gt;
     &lt;option value="48"&gt;Enlistee's&lt;/option&gt;
     &lt;option value="74"&gt;First Platoon Leadership&lt;/option&gt;
     &lt;option value="50"&gt;First Platoon, First Squad&lt;/option&gt;
     &lt;option value="61"&gt;First Platoon, Fourth Squad&lt;/option&gt;
     &lt;option value="51"&gt;First Platoon, Second Squad&lt;/option&gt;
     &lt;option value="46"&gt;First Platoon, Third Squad&lt;/option&gt;
     &lt;option value="11"&gt;Force Improvement Group&lt;/option&gt;
     &lt;option value="2"&gt;Guests&lt;/option&gt;
     &lt;option value="63"&gt;PERSCOM System&lt;/option&gt;
     &lt;option value="14"&gt;Public Affairs Office&lt;/option&gt;
     &lt;option value="12"&gt;Recruiting and Retention Office&lt;/option&gt;
     &lt;option value="49"&gt;Retired Personnel&lt;/option&gt;
     &lt;option value="75"&gt;Second Platoon Leadership&lt;/option&gt;
     &lt;option value="69"&gt;Second Platoon, First Squad&lt;/option&gt;
     &lt;option value="72"&gt;Second Platoon, Fourth Squad&lt;/option&gt;
     &lt;option value="70"&gt;Second Platoon, Second Squad&lt;/option&gt;
     &lt;option value="71"&gt;Second Platoon, Third Squad&lt;/option&gt;
     &lt;option value="76"&gt;Third Platoon Leadership&lt;/option&gt;
     &lt;option value="52"&gt;Third Platoon, First Squad&lt;/option&gt;
     &lt;option value="73"&gt;Third Platoon, Fourth Squad&lt;/option&gt;
     &lt;option value="65"&gt;Third Platoon, Second Squad&lt;/option&gt;
     &lt;option value="66"&gt;Third Platoon, Third Squad&lt;/option&gt;
     &lt;option value="1"&gt;Validating&lt;/option&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>As you can see, the value is being set to 3, yet, 2nd Aviation Detachment is the option being shown.</p>