title: Javascript: Uncaught TypeError: Cannot set property 'value' of null
body: <p>I am trying to set a value of a textbox and I get this error...
  Please see my code:</p>
  
  <p><strong>this is my textbox</strong></p>
  
  <pre><code>&lt;input id="Text1" type="text" runat="server"/&gt;
  </code></pre>
  
  <p><strong>this is my drop down list</strong></p>
  
  <pre><code>&lt;select id="title" name="D1" onchange="Select()" &gt;
                  &lt;option selected="selected"&gt;&lt;/option&gt;
                  &lt;option value="1"&gt;Pilot&lt;/option&gt;
                  &lt;option value="5"&gt;Engineer&lt;/option&gt;                                    
               &lt;/select&gt;
  </code></pre>
  
  <p><strong>And that is my function</strong></p>
  
  <pre><code>  &lt;script type="text/javascript"&gt;
  
  
      function Select() {
  
          var ddl = document.getElementById("title");
          var selected = ddl.options[ddl.selectedIndex].value;
          document.getElementById("Text1").value = selected;
          alert(document.getElementById("Text1").value);
          if (selected == "5") {
              document.getElementById('divTechnician').style.visibility = "visible";
          } else {
              document.getElementById('divTechnician').style.visibility = "hidden";
  
          }            
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>Error occurs when I try to assign value to this text box </p>
  
  <pre><code>document.getElementById("Text1").value = selected;
  </code></pre>