title: javascript selected value
body: <pre><code>            &lt;div id="selected_options"&gt;
              &lt;select onchange="test()" id="selected_options"&gt;
              &lt;option value="0" selected&gt;-Select-&lt;/option&gt;
              &lt;option value="1"&gt;Communication&lt;/option&gt;
              &lt;option value="2"&gt;Hardware&lt;/option&gt;
              &lt;/select&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>i had written a function for selected value , but when i'm doing alert of selected value it showing up undefined , the function is </p>
  
  <pre><code>      function test() {
                      var get_id = document.getElementById('selected_options');
                      var result = get_id.options[get_id.selectedIndex].value;
                      alert(result);
                        }
  </code></pre>
  
  <p>any one please tell me what is the error?</p>