title: How to get selected index of a Html select in asp.net?
body: <p>I have code below:</p>
  
  <pre><code> &lt;select id="test"&gt;
          &lt;option value="a"&gt;aaa&lt;/option&gt;
          &lt;option value="b"&gt;bbb&lt;/option&gt;
      &lt;/select&gt;
      &lt;asp:Button ID="btnTest" runat="server" Text="Test it!" onclick="btnTest_Click" /&gt;
  </code></pre>
  
  <p>I need to get selected index not selected value on postback. How can I do this with asp.net?
  this is my code for filling the select html:</p>
  
  <pre><code>&lt;script language="javascript" type="text/javascript"&gt;
      $(document).ready(function() {
      $("#&lt;%=btnTest.ClientID %&gt;").click(function(){
      $.ajax(
      { url: "StateCity.asmx/ReferItems?id=" + getParameterByName('id'),
          contentType: "application/json; charset=utf-8",
          dataType: "json",
          type: "POST",
          success: function(data) {
          $("#test").empty();
          $.each(data.d, function() {
          $("#test").append($("&lt;option&gt;&lt;/option&gt;").val(this['Value']).html(this['Text']));
          });
  
          },
          error: function() { alert("Error"); }
      }) 
      })
  &lt;/script&gt;
  </code></pre>