title: How to fix unresponsive external javascript file linked to html
body: <p>I'm trying to create an interactive time table using HTML and (external) JavaScript for a class project. Despite following the code given by my lecturer, the JavaScript doesn't seem to respond when the radio buttons are clicked on.</p>
  
  <p>This is for a class project to be hosted online. I'm creating the page using HTML5, W3.CSS and JavaScript. I've tried several solutions for similar problems listed on here, such as moving the script tag to the top (and bottom) of the  tag. I've also tried removing the head tag with no success.</p>
  
  <p>HTML code :</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
  &lt;title&gt;Times Tables&lt;/title&gt;
  &lt;meta charset="UTF-8"&gt;
  &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
  &lt;link rel="stylesheet" type="text/css" href="css/w3.css"&gt;
  &lt;link rel="icon" type="image/png" href="images/icon.png"&gt;
  &lt;style&gt;
  body,h1,h2,h3,h4,h5,h6 {font-family: "Arial", sans-serif}
  .w3-bar,h1,button {font-family: "Verdana", sans-serif}
  &lt;script type="text/javascript" src="jScripts/TimeTableFile.js"&gt;&lt;/script&gt;
  &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;!-- Header --&gt;
  &lt;header class="w3-container w3-light-blue w3-center" style="padding:64px 16px"&gt;
    &lt;h1 class="w3-margin w3-xlarge"&gt;Times Tables&lt;/h1&gt;
  &lt;/header&gt;
  
  &lt;!-- First Grid --&gt;
  &lt;div class="w3-row-padding w3-padding-64 w3-container w3-pale-yellow"&gt;
  &lt;div class="w3-content"&gt;
  &lt;table&gt;
  &lt;tr&gt;
  &lt;td&gt;Pick a number&lt;/td&gt;
  &lt;td&gt;
  &lt;select id="mySelect"&gt;
  &lt;option value="1"&gt;1&lt;/option&gt;
  &lt;option value="2"&gt;2&lt;/option&gt;
  &lt;option value="3"&gt;3&lt;/option&gt;
  &lt;option value="4"&gt;4&lt;/option&gt;
  &lt;option value="5"&gt;5&lt;/option&gt;
  &lt;option value="6"&gt;6&lt;/option&gt;
  &lt;option value="7"&gt;7&lt;/option&gt;
  &lt;option value="8"&gt;8&lt;/option&gt;
  &lt;option value="9"&gt;9&lt;/option&gt;
  &lt;option value="10"&gt;10&lt;/option&gt;
  &lt;option value="11"&gt;11&lt;/option&gt;
  &lt;option value="12"&gt;12&lt;/option&gt;
  &lt;option value="13"&gt;13&lt;/option&gt;
  &lt;option value="14"&gt;14&lt;/option&gt;
  &lt;option value="15"&gt;15&lt;/option&gt;
  &lt;option value="16"&gt;16&lt;/option&gt;
  &lt;option value="17"&gt;17&lt;/option&gt;
  &lt;option value="18"&gt;18&lt;/option&gt;
  &lt;option value="19"&gt;19&lt;/option&gt;
  &lt;option value="20"&gt;20&lt;/option&gt;
  &lt;/select&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
  &lt;td&gt;&lt;input type="button" id="reset" value="Clear"&gt;&lt;/input&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="button" id="calc" value="Calculate"&gt;&lt;/input&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  &lt;hr&gt;
          &lt;table&gt;         
              &lt;tr&gt;
                  &lt;td colspan="2" id="tables"&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
          &lt;hr&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  &lt;!-- Footer --&gt;
  &lt;footer class="w3-container w3-padding-32 w3-center w3-deep-purple"&gt;  
    &lt;div class="w3-xlarge w3-padding-16"&gt;
   &lt;/div&gt;
   &lt;h6&gt;
      &amp;copy; 2019
   &lt;/h6&gt;
   &lt;h6&gt;Website template by &lt;a href="https://www.w3schools.com/w3css/default.asp" target="_blank"&gt;w3.css&lt;/a&gt;&lt;/h6&gt;
  &lt;/footer&gt;
  
  &lt;script&gt;
  // Used to toggle the menu on small screens when clicking on the menu button
  function myFunction() {
    var x = document.getElementById("navDemo");
    if (x.className.indexOf("w3-show") == -1) {
      x.className += " w3-show";
    } else { 
      x.className = x.className.replace(" w3-show", "");
    }
  }
  &lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>JavaScript code:</p>
  
  <pre><code>var $ = function(id){
      return document.getElementById(id);
  };
  var ResetTextfields = function(){
      $("tables").innerHTML ="Please select a number to generate tables";
  };
  var calculate = function(){
      var number = parseInt($("mySelect").value);
      if(isNaN(number))
          alert("Please select a number from the list");
      else{
          var res = "The "+number+" times tables:&lt;br&gt;";
          for(var i=1; i&lt;=number; i++)
              res+=number+"x "+i+" = "+(number*i)+"&lt;br&gt;";
          $("tables").innerHTML =res;
      }
  };
  window.onload = function(){
      $("calc").onclick = function(){calculate();}
      $("reset").onclick = function(){ResetTextfields();}
  };
  </code></pre>
  
  <p>W3.CSS is just a template taken from the w3schools website.</p>
  
  <p>What I expect to happen is that when the user clicks on the "calculate" button: a time table is generated based on what number the user picks, and when "reset" is clicked on, the page is reset so that any previous time table disappears.</p>
  
  <p>However, when I click on either of these buttons, nothing happens. The  function works fine, it's just the  buttons don't do anything. </p>
  
  <p>Is there any particular reason why this is happening? AFAIK, the code's all correct, the only thing that I'm doing differently is using W3.CSS, which even then shouldn't effect the Javascript. If anybody has any solutions it'd be much appreciated, thanks!</p>