title: js - call the same value in body onload to an onclick function
body: <p>i am trying to get the same value string that i get from the prompt box, to a function that run in onclick event.
  is it possible in that kind of way?
  Thanks in advance..</p>
  
  <pre><code>    &lt;!DOCOTYPE html&gt;
      &lt;html&gt;
      &lt;head&gt;
      &lt;/head&gt;
      &lt;body onLoad = "h1();"&gt;
  
      &lt;form&gt;
      &lt;input type="button" value="function h3()" onClick="h3()"&gt;
      &lt;/form&gt;
  
      &lt;script type="text/javascript"&gt;
  
          function h1(){
          var x = prompt("");
          console.log(x);
          return h2(x);
          }
  
          function h2(str){
          console.log("get value from h1 function" + "   " + str);
          }
  
  
          function h3(){
          console.log("return the value from h1 to h2");
          return h2(str);
  
          }
      &lt;/script&gt;
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>