title: Getting the value of a dropdown list by javascript is not working.
body: <p>I have done this a million time and every time has worked, but I cannot get it to work this time and I have no clue why.</p>
  
  <p>I have a dropdown list and I need to get the selected value of the dropdown list in javascript.</p>
  
  <pre><code>    &lt;asp:DropDownList runat="server" ID="ddlCompanies"  AutoPostBack="true"&gt;
      &lt;asp:ListItem Value="Microsoft Corporation, One Microsoft Way, Redmond, WA 98052-7329,USA"&gt;Microsoft Corporation&lt;/asp:ListItem&gt; 
      &lt;asp:ListItem Value="1600 Amphitheatre Parkway, Mountain View, CA 94043"&gt;Google Inc.&lt;/asp:ListItem&gt; 
      &lt;asp:ListItem Value="500 Oracle Parkway,Redwood Shores, CA 94065"&gt;Oracle Corporation&lt;/asp:ListItem&gt; 
      &lt;asp:ListItem Value="One Dell Way,Round Rock, Texas 78682,United States"&gt;Dell Inc.&lt;/asp:ListItem&gt; 
      &lt;/asp:DropDownList&gt;
  </code></pre>
  
  <p>My javascript code is:</p>
  
  <pre><code>    function findAddress() {
      if (document.getElementById("ddlCompanies") == null )
      return false;
      else{
       var ddlAddress = document.getElementById("ddlCompanies");
       var value = ddlAddress.getAttribute('value');
       var dllAddressIndex = ddlAddress.selectedIndex;
       var dllAddressValue = dllAddressIndex.value;
       var options = dllAddress.options[0];
              var address = ddlAddress.options[ddlAddress.selectedIndex].value;  // get selected address from dropdownlist
              showAddress(address); 
              return false;   // avoid postback
              }
      }
  </code></pre>
  
  <p>I run this code in debug mode in firebug and I can clearly see that the value of the selected index is null. In fact, the code breaks when it reaches dllAddress.options. I also tried .text instead of .value, it still doesn't work. Please help I have spent 2 days on this. Thanks.</p>
  
  <p>They don't let me to post an image of firebug debugger, but I can see that the selectedindex is picked up by javascript, but the value remains null. </p>