title: HTML JavaScript Dropdown selectedIndex
body: <p>I'm trying to get the dropdown to change the textbox, but seem to be having issues. </p>
  
  <pre><code>&lt;head&gt;
      &lt;title&gt;DropDown&lt;/title&gt;
      &lt;meta http-equiv="content-type" content="text/html;charset=utf-8" /&gt;
      &lt;meta name="generator" content="Geany 0.20" /&gt;
      &lt;script type="text/javascript"&gt;
          function chkind() {
              var dropdown1 = document.getElementById('dropdown1');
              var textbox = document.getElementById('textbox');
              var a = dropdown1.options[dropdown1.selectedIndex];
              if(a == 0){
                  textbox.value = "hi";
              } else if(a == 1) {
              textbox.value = "bye";
          }
      }
      &lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body&gt;
      &lt;select onchange="chkind()" id="dropdown1"&gt;
          &lt;option&gt;Hi&lt;/option&gt;
          &lt;option&gt;Bye&lt;/option&gt;
      &lt;/select&gt;&lt;br /&gt;
      &lt;input id="textbox" type="text" /&gt;
  &lt;/body&gt;
  </code></pre>