title: Undefined function in javascript
body: <p>I'm encountering an error that doesn't seem to make sense. 
  Chrome's console is saying <code>Uncaught ReferenceError: clicked_server is not defined</code></p>
  
  <p>I tried almost everything to fix it but the error itself doesn't make much sense</p>
  
  <pre><code>&lt;script&gt;
      var selected_char = 'X';
  
      function draw_list () {
          // lets draw an x in all server in the array
          var server_id = 0;
          var draw_servers = new Array();
          draw_servers = document.getElementById("server_arr").value.split(";");
  
          foreach(draw_servers as server_id) {
              document.getElementById("server("+server_id+")").innerHTML = selected_char;
          }    
          // Update the counter and servers array
          server_count_field.innerHTML = "Buy Server("+servers_array.length+")";
      }
  
      function clicked_server(server_id) {
           var clicked = document.getElementById("server("+server_id+")").innerHTML;
           if (clicked == selected_char) remove_server(server_id);
           else add_server(server_id);
      }
  
      window.onload = draw_list();
  
  
      function add_server(server_id) {
          // select a server for purchase
          var servers_array = document.getElementById("server_arr").value;
  
          if(servers_array.length &gt; 0) servers_array = servers_array + ";" + server;
          else servers_array = server;
  
          document.getElementById("server_arr").value = servers_array;
      }
  &lt;/script&gt; 
  </code></pre>
  
  <p>My HTML is working perfectly. Here it is</p>
  
  <pre><code>&lt;form action="dobuyserver.php" method="POST"&gt;
      &lt;input type="hidden" name="server" id="server_arr"/&gt;
      &lt;input type="submit" value="Buy Server(0)" id="server_count"/&gt;
      &lt;/form&gt;
  
  &lt;td style="background-color:##000000;" onclick="clicked_server(9)"&gt;&lt;font color="#FFFFFF"&gt;
                          &lt;strong&gt;
                          &lt;span id="server(9)"&gt;
                          &amp;nbsp;
                          &lt;/span&gt;
                          &lt;/strong&gt;
                          &lt;/font&gt;&lt;/td&gt;
  </code></pre>