title: How to pass a variable into another function to be called - Javascript
body: <p>I am trying to get this to work: </p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;body&gt;
  
  &lt;form&gt;&lt;input type='button' id='confirm' value="Confirm"/&gt;&lt;/form&gt;
  &lt;p id="getvariable"&gt;&lt;/p&gt;
  
  &lt;script&gt; 
  function a(){var t= 5;}
  function b(){return t;}
  
  document.getElementById('confirm').onclick = function(){
  document.getElementById("getvariable").innerHTML = b();}
  
  &lt;/script&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>but I can't pass a variable to the other function. Any help would be great!</p>