title: read variable from dropdown function in javascript
body: <p>i am using this dropdown in html file:</p>
  
  <pre><code>&lt;select id="read-type"  onchange="checkrt()"&gt;                           
                      &lt;option value="1"&gt;2word&lt;/option&gt;                    
                      &lt;option value="2"&gt;3word&lt;/option&gt;
                      &lt;option value="3"&gt;line&lt;/option&gt;
                      &lt;/select&gt;
              &lt;/div&gt;
  </code></pre>
  
  <p>and read it by:</p>
  
  <pre><code>var dro = document.getElementById("read-type");
  var readtype = dro.options[dro.selectedIndex].value;
  </code></pre>
  
  <p>but this code can't read "onchange" or i don't now how?, so i change the code to:</p>
  
  <pre><code>$(function checkrt(){
      $('#read-type').on('change', function(){        
          window.readtype = $(this).val();
          alert(readtype);
      });
  })
  </code></pre>
  
  <p>the last code work good with "alert", but i can't read the the variable "readtype" in the next function by:</p>
  
  <pre><code>    Function delta(text){
  if (readtype == 1) 
  </code></pre>
  
  <p>this give me msg (un define readtype)?, please what th problem.</p>
  
  <p>note: the code can get readtype if i clicked on "refresh" button in the browser after i change the selected item in dropdown.</p>
  
  <ul>
  <li>the code in app.js not in html.</li>
  </ul>